31 #include <sys/types.h> 
   44 using namespace v8::internal;
 
   48 static void InitializeVM() {
 
   83   if (FLAG_never_compact) 
return;
 
   87   FLAG_gc_global = 
true;
 
   88   FLAG_always_compact = 
true;
 
   99   Object* obj = 
HEAP->AllocateFixedArray(array_size)->ToObjectChecked();
 
  131   Object* obj = i::Isolate::Current()->heap()->AllocateFixedArray(length)->
 
  143     { MaybeObject* maybe_obj = 
HEAP->AllocateFixedArray(100, 
TENURED);
 
  144       if (!maybe_obj->ToObject(&obj)) 
break;
 
  166   MaybeObject* maybe_array;
 
  168     maybe_array = 
HEAP->AllocateFixedArray(ARRAY_SIZE);
 
  169   } 
while (maybe_array->ToObject(&array));
 
  172   array = 
HEAP->AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked();
 
  176   MaybeObject* maybe_mapp;
 
  179   } 
while (maybe_mapp->ToObject(&mapp));
 
  188       HEAP->AllocateSharedFunctionInfo(func_name)->ToObjectChecked());
 
  190       HEAP->AllocateFunction(*Isolate::Current()->function_map(),
 
  192                              HEAP->undefined_value())->ToObjectChecked());
 
  196   function->set_initial_map(initial_map);
 
  197   Isolate::Current()->context()->global()->SetProperty(
 
  201       HEAP->AllocateJSObject(
function)->ToObjectChecked());
 
  206   CHECK(Isolate::Current()->context()->global()->HasLocalProperty(func_name));
 
  207   Object* func_value = Isolate::Current()->context()->global()->
 
  209   CHECK(func_value->IsJSFunction());
 
  215   Isolate::Current()->context()->global()->SetProperty(
 
  228   CHECK(Isolate::Current()->context()->global()->HasLocalProperty(obj_name));
 
  229   CHECK(Isolate::Current()->context()->global()->
 
  230         GetProperty(obj_name)->ToObjectChecked()->IsJSObject());
 
  247   FLAG_max_map_space_pages = 16;
 
  257       map->set_prototype(*root);
 
  258       root = 
FACTORY->NewJSObjectFromMap(map);
 
  259     } 
while (
HEAP->map_space()->MapPointersEncodable());
 
  265   HEAP->CollectAllGarbage(Heap::kForceCompactionMask);
 
  267   CHECK(
HEAP->map_space()->MapPointersEncodable());
 
  271 static int gc_starts = 0;
 
  272 static int gc_ends = 0;
 
  274 static void GCPrologueCallbackFunc() {
 
  275   CHECK(gc_starts == gc_ends);
 
  280 static void GCEpilogueCallbackFunc() {
 
  281   CHECK(gc_starts == gc_ends + 1);
 
  289   HEAP->SetGlobalGCPrologueCallback(&GCPrologueCallbackFunc);
 
  290   HEAP->SetGlobalGCEpilogueCallback(&GCEpilogueCallbackFunc);
 
  293   HEAP->PerformScavenge();
 
  304 static int NumberOfWeakCalls = 0;
 
  306   ASSERT(
id == reinterpret_cast<void*>(1234));
 
  313   GlobalHandles* global_handles = Isolate::Current()->global_handles();
 
  315   NumberOfWeakCalls = 0;
 
  319       global_handles->
Create(
HEAP->AllocateFixedArray(1)->ToObjectChecked());
 
  321       global_handles->
Create(
HEAP->AllocateFixedArray(1)->ToObjectChecked());
 
  323       global_handles->
Create(
HEAP->AllocateFixedArray(1)->ToObjectChecked());
 
  325                            reinterpret_cast<void*
>(1234),
 
  326                            &WeakPointerCallback);
 
  328                            reinterpret_cast<void*
>(1234),
 
  329                            &WeakPointerCallback);
 
  331                            reinterpret_cast<void*
>(1234),
 
  332                            &WeakPointerCallback);
 
  335       global_handles->
Create(
HEAP->AllocateFixedArray(1)->ToObjectChecked());
 
  337     global_handles->
Create(
HEAP->AllocateFixedArray(1)->ToObjectChecked());
 
  339     global_handles->
Create(
HEAP->AllocateFixedArray(1)->ToObjectChecked());
 
  341                            reinterpret_cast<void*
>(1234),
 
  342                            &WeakPointerCallback);
 
  344                            reinterpret_cast<void*
>(1234),
 
  345                            &WeakPointerCallback);
 
  347                            reinterpret_cast<void*
>(1234),
 
  348                            &WeakPointerCallback);
 
  376                            reinterpret_cast<void*
>(1234),
 
  377                            &WeakPointerCallback);
 
  404                            reinterpret_cast<void*
>(1234),
 
  405                            &WeakPointerCallback);
 
  407                            reinterpret_cast<void*
>(1234),
 
  408                            &WeakPointerCallback);
 
  422     ASSERT(!has_been_disposed_);
 
  423     has_been_disposed_ = 
true;
 
  427     return other == 
this;
 
  432   virtual const char* 
GetLabel() { 
return "whatever"; }
 
  435   bool has_been_disposed_;
 
  441   GlobalHandles* global_handles = Isolate::Current()->global_handles();
 
  446       global_handles->
Create(
HEAP->AllocateFixedArray(1)->ToObjectChecked());
 
  460 #if defined(__linux__) && !defined(USE_SIMULATOR) 
  463 static uintptr_t ReadLong(
char* buffer, intptr_t* position, 
int base) {
 
  464   char* end_address = buffer + *position;
 
  465   uintptr_t result = strtoul(buffer + *position, &end_address, base);
 
  466   CHECK(result != ULONG_MAX || errno != ERANGE);
 
  467   CHECK(end_address > buffer + *position);
 
  468   *position = end_address - buffer;
 
  473 static intptr_t MemoryInUse() {
 
  474   intptr_t memory_use = 0;
 
  476   int fd = open(
"/proc/self/maps", O_RDONLY);
 
  477   if (fd < 0) 
return -1;
 
  479   const int kBufSize = 10000;
 
  480   char buffer[kBufSize];
 
  481   int length = read(fd, buffer, kBufSize);
 
  482   intptr_t line_start = 0;
 
  485   while (line_start < length) {
 
  486     if (buffer[line_start] == 
'\n') {
 
  490     intptr_t position = line_start;
 
  491     uintptr_t start = ReadLong(buffer, &position, 16);
 
  493     uintptr_t end = ReadLong(buffer, &position, 16);
 
  495     CHECK(buffer[position] == 
'-' || buffer[position] == 
'r');
 
  496     bool read_permission = (buffer[position++] == 
'r');
 
  497     CHECK(buffer[position] == 
'-' || buffer[position] == 
'w');
 
  498     bool write_permission = (buffer[position++] == 
'w');
 
  499     CHECK(buffer[position] == 
'-' || buffer[position] == 
'x');
 
  500     bool execute_permission = (buffer[position++] == 
'x');
 
  501     CHECK(buffer[position] == 
'-' || buffer[position] == 
'p');
 
  502     bool private_mapping = (buffer[position++] == 
'p');
 
  504     uintptr_t offset = ReadLong(buffer, &position, 16);
 
  507     uintptr_t major = ReadLong(buffer, &position, 16);
 
  510     uintptr_t minor = ReadLong(buffer, &position, 16);
 
  513     uintptr_t inode = ReadLong(buffer, &position, 10);
 
  514     while (position < length && buffer[position] != 
'\n') position++;
 
  515     if ((read_permission || write_permission || execute_permission) &&
 
  516         private_mapping && inode == 0) {
 
  517       memory_use += (end - start);
 
  520     line_start = position;
 
  527 TEST(BootUpMemoryUse) {
 
  528   intptr_t initial_memory = MemoryInUse();
 
  529   FLAG_crankshaft = 
false;  
 
  532   if (initial_memory >= 0) {
 
  534     intptr_t delta = MemoryInUse() - initial_memory;
 
  535     if (
sizeof(initial_memory) == 8) {
 
  551 #endif  // __linux__ and !USE_SIMULATOR 
static Handle< Object > SetProperty(Handle< JSReceiver > object, Handle< String > key, Handle< Object > value, PropertyAttributes attributes, StrictModeFlag strict_mode)
#define CHECK_EQ(expected, value)
static String * cast(Object *obj)
static Smi * FromInt(int value)
static Handle< T > cast(Handle< S > that)
void AddImplicitReferences(HeapObject **parent, Object ***children, size_t length)
static Map * cast(Object *obj)
#define ASSERT(condition)
void ClearWeakness(Object **location)
static SharedFunctionInfo * cast(Object *obj)
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
void AddObjectGroup(Object ***handles, size_t length, v8::RetainedObjectInfo *info)
virtual bool IsEquivalent(v8::RetainedObjectInfo *other)
void PushBlack(HeapObject *object)
Handle< Object > Create(Object *value)
void Initialize(Address low, Address high)
static const int kMaxNonCodeHeapObjectSize
virtual intptr_t GetHash()
static const int kHeaderSize
virtual const char * GetLabel()
MUST_USE_RESULT MaybeObject * GetProperty(String *key)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static HeapObject * FromAddress(Address address)
static FixedArray * cast(Object *obj)
static const int kHeaderSize
static Persistent< Context > New(ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
void MakeWeak(Object **location, void *parameter, WeakReferenceCallback callback)
void DeleteArray(T *array)
static JSObject * cast(Object *obj)
static JSFunction * cast(Object *obj)