| Index: src/objects.cc
|
| ===================================================================
|
| --- src/objects.cc (revision 7563)
|
| +++ src/objects.cc (working copy)
|
| @@ -52,7 +52,6 @@
|
| #include "disassembler.h"
|
| #endif
|
|
|
| -
|
| namespace v8 {
|
| namespace internal {
|
|
|
| @@ -65,7 +64,8 @@
|
| MUST_USE_RESULT static MaybeObject* CreateJSValue(JSFunction* constructor,
|
| Object* value) {
|
| Object* result;
|
| - { MaybeObject* maybe_result = Heap::AllocateJSObject(constructor);
|
| + { MaybeObject* maybe_result =
|
| + constructor->GetHeap()->AllocateJSObject(constructor);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| JSValue::cast(result)->set_value(value);
|
| @@ -87,14 +87,19 @@
|
|
|
|
|
| MaybeObject* Object::ToObject() {
|
| - Context* global_context = Top::context()->global_context();
|
| if (IsJSObject()) {
|
| return this;
|
| } else if (IsNumber()) {
|
| + Isolate* isolate = Isolate::Current();
|
| + Context* global_context = isolate->context()->global_context();
|
| return CreateJSValue(global_context->number_function(), this);
|
| } else if (IsBoolean()) {
|
| + Isolate* isolate = HeapObject::cast(this)->GetIsolate();
|
| + Context* global_context = isolate->context()->global_context();
|
| return CreateJSValue(global_context->boolean_function(), this);
|
| } else if (IsString()) {
|
| + Isolate* isolate = HeapObject::cast(this)->GetIsolate();
|
| + Context* global_context = isolate->context()->global_context();
|
| return CreateJSValue(global_context->string_function(), this);
|
| }
|
|
|
| @@ -104,35 +109,43 @@
|
|
|
|
|
| Object* Object::ToBoolean() {
|
| - if (IsTrue()) return Heap::true_value();
|
| - if (IsFalse()) return Heap::false_value();
|
| + if (IsTrue()) return this;
|
| + if (IsFalse()) return this;
|
| if (IsSmi()) {
|
| - return Heap::ToBoolean(Smi::cast(this)->value() != 0);
|
| + return Isolate::Current()->heap()->ToBoolean(Smi::cast(this)->value() != 0);
|
| }
|
| - if (IsUndefined() || IsNull()) return Heap::false_value();
|
| + if (IsUndefined() || IsNull()) {
|
| + return HeapObject::cast(this)->GetHeap()->false_value();
|
| + }
|
| // Undetectable object is false
|
| if (IsUndetectableObject()) {
|
| - return Heap::false_value();
|
| + return HeapObject::cast(this)->GetHeap()->false_value();
|
| }
|
| if (IsString()) {
|
| - return Heap::ToBoolean(String::cast(this)->length() != 0);
|
| + return HeapObject::cast(this)->GetHeap()->ToBoolean(
|
| + String::cast(this)->length() != 0);
|
| }
|
| if (IsHeapNumber()) {
|
| return HeapNumber::cast(this)->HeapNumberToBoolean();
|
| }
|
| - return Heap::true_value();
|
| + return Isolate::Current()->heap()->true_value();
|
| }
|
|
|
|
|
| void Object::Lookup(String* name, LookupResult* result) {
|
| if (IsJSObject()) return JSObject::cast(this)->Lookup(name, result);
|
| Object* holder = NULL;
|
| - Context* global_context = Top::context()->global_context();
|
| if (IsString()) {
|
| + Heap* heap = HeapObject::cast(this)->GetHeap();
|
| + Context* global_context = heap->isolate()->context()->global_context();
|
| holder = global_context->string_function()->instance_prototype();
|
| } else if (IsNumber()) {
|
| + Heap* heap = Isolate::Current()->heap();
|
| + Context* global_context = heap->isolate()->context()->global_context();
|
| holder = global_context->number_function()->instance_prototype();
|
| } else if (IsBoolean()) {
|
| + Heap* heap = HeapObject::cast(this)->GetHeap();
|
| + Context* global_context = heap->isolate()->context()->global_context();
|
| holder = global_context->boolean_function()->instance_prototype();
|
| }
|
| ASSERT(holder != NULL); // Cannot handle null or undefined.
|
| @@ -155,6 +168,7 @@
|
| Object* structure,
|
| String* name,
|
| Object* holder) {
|
| + Isolate* isolate = name->GetIsolate();
|
| // To accommodate both the old and the new api we switch on the
|
| // data structure used to store the callbacks. Eventually proxy
|
| // callbacks should be phased out.
|
| @@ -162,7 +176,7 @@
|
| AccessorDescriptor* callback =
|
| reinterpret_cast<AccessorDescriptor*>(Proxy::cast(structure)->proxy());
|
| MaybeObject* value = (callback->getter)(receiver, callback->data);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return value;
|
| }
|
|
|
| @@ -175,17 +189,19 @@
|
| JSObject* self = JSObject::cast(receiver);
|
| JSObject* holder_handle = JSObject::cast(holder);
|
| Handle<String> key(name);
|
| - LOG(ApiNamedPropertyAccess("load", self, name));
|
| - CustomArguments args(data->data(), self, holder_handle);
|
| + LOG(isolate, ApiNamedPropertyAccess("load", self, name));
|
| + CustomArguments args(isolate, data->data(), self, holder_handle);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = call_fun(v8::Utils::ToLocal(key), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| - if (result.IsEmpty()) return Heap::undefined_value();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| + if (result.IsEmpty()) {
|
| + return isolate->heap()->undefined_value();
|
| + }
|
| return *v8::Utils::OpenHandle(*result);
|
| }
|
|
|
| @@ -197,7 +213,7 @@
|
| JSFunction::cast(getter));
|
| }
|
| // Getter is not a function.
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| UNREACHABLE();
|
| @@ -211,9 +227,10 @@
|
| Handle<JSFunction> fun(JSFunction::cast(getter));
|
| Handle<Object> self(receiver);
|
| #ifdef ENABLE_DEBUGGER_SUPPORT
|
| + Debug* debug = fun->GetHeap()->isolate()->debug();
|
| // Handle stepping into a getter if step into is active.
|
| - if (Debug::StepInActive()) {
|
| - Debug::HandleStepIn(fun, Handle<Object>::null(), 0, false);
|
| + if (debug->StepInActive()) {
|
| + debug->HandleStepIn(fun, Handle<Object>::null(), 0, false);
|
| }
|
| #endif
|
| bool has_pending_exception;
|
| @@ -231,6 +248,7 @@
|
| LookupResult* result,
|
| String* name,
|
| PropertyAttributes* attributes) {
|
| + Heap* heap = name->GetHeap();
|
| if (result->IsProperty()) {
|
| switch (result->type()) {
|
| case CALLBACKS: {
|
| @@ -282,8 +300,8 @@
|
|
|
| // No accessible property found.
|
| *attributes = ABSENT;
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_GET);
|
| - return Heap::undefined_value();
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| @@ -292,6 +310,7 @@
|
| LookupResult* result,
|
| String* name,
|
| bool continue_search) {
|
| + Heap* heap = name->GetHeap();
|
| if (result->IsProperty()) {
|
| switch (result->type()) {
|
| case CALLBACKS: {
|
| @@ -345,7 +364,7 @@
|
| }
|
| }
|
|
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return ABSENT;
|
| }
|
|
|
| @@ -379,16 +398,14 @@
|
| Object* value,
|
| PropertyDetails details) {
|
| ASSERT(!HasFastProperties());
|
| + Heap* heap = name->GetHeap();
|
| int entry = property_dictionary()->FindEntry(name);
|
| if (entry == StringDictionary::kNotFound) {
|
| Object* store_value = value;
|
| if (IsGlobalObject()) {
|
| - { MaybeObject* maybe_store_value =
|
| - Heap::AllocateJSGlobalPropertyCell(value);
|
| - if (!maybe_store_value->ToObject(&store_value)) {
|
| - return maybe_store_value;
|
| - }
|
| - }
|
| + MaybeObject* maybe_store_value =
|
| + heap->AllocateJSGlobalPropertyCell(value);
|
| + if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value;
|
| }
|
| Object* dict;
|
| { MaybeObject* maybe_dict =
|
| @@ -417,6 +434,7 @@
|
|
|
| MaybeObject* JSObject::DeleteNormalizedProperty(String* name, DeleteMode mode) {
|
| ASSERT(!HasFastProperties());
|
| + Heap* heap = GetHeap();
|
| StringDictionary* dictionary = property_dictionary();
|
| int entry = dictionary->FindEntry(name);
|
| if (entry != StringDictionary::kNotFound) {
|
| @@ -424,7 +442,7 @@
|
| if (IsGlobalObject()) {
|
| PropertyDetails details = dictionary->DetailsAt(entry);
|
| if (details.IsDontDelete()) {
|
| - if (mode != FORCE_DELETION) return Heap::false_value();
|
| + if (mode != FORCE_DELETION) return heap->false_value();
|
| // When forced to delete global properties, we have to make a
|
| // map change to invalidate any ICs that think they can load
|
| // from the DontDelete cell without checking if it contains
|
| @@ -437,13 +455,13 @@
|
| }
|
| JSGlobalPropertyCell* cell =
|
| JSGlobalPropertyCell::cast(dictionary->ValueAt(entry));
|
| - cell->set_value(Heap::the_hole_value());
|
| + cell->set_value(heap->the_hole_value());
|
| dictionary->DetailsAtPut(entry, details.AsDeleted());
|
| } else {
|
| return dictionary->DeleteProperty(entry, mode);
|
| }
|
| }
|
| - return Heap::true_value();
|
| + return heap->true_value();
|
| }
|
|
|
|
|
| @@ -469,6 +487,7 @@
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| + Heap* heap = name->GetHeap();
|
|
|
| // Traverse the prototype chain from the current object (this) to
|
| // the holder and check for access rights. This avoid traversing the
|
| @@ -476,7 +495,7 @@
|
| // holder will always be the interceptor holder and the search may
|
| // only continue with a current object just after the interceptor
|
| // holder in the prototype chain.
|
| - Object* last = result->IsProperty() ? result->holder() : Heap::null_value();
|
| + Object* last = result->IsProperty() ? result->holder() : heap->null_value();
|
| for (Object* current = this; true; current = current->GetPrototype()) {
|
| if (current->IsAccessCheckNeeded()) {
|
| // Check if we're allowed to read from the current object. Note
|
| @@ -484,7 +503,7 @@
|
| // property from the current object, we still check that we have
|
| // access to it.
|
| JSObject* checked = JSObject::cast(current);
|
| - if (!Top::MayNamedAccess(checked, name, v8::ACCESS_GET)) {
|
| + if (!heap->isolate()->MayNamedAccess(checked, name, v8::ACCESS_GET)) {
|
| return checked->GetPropertyWithFailedAccessCheck(receiver,
|
| result,
|
| name,
|
| @@ -499,7 +518,7 @@
|
|
|
| if (!result->IsProperty()) {
|
| *attributes = ABSENT;
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
| *attributes = result->GetAttributes();
|
| Object* value;
|
| @@ -508,11 +527,11 @@
|
| case NORMAL:
|
| value = holder->GetNormalizedProperty(result);
|
| ASSERT(!value->IsTheHole() || result->IsReadOnly());
|
| - return value->IsTheHole() ? Heap::undefined_value() : value;
|
| + return value->IsTheHole() ? heap->undefined_value() : value;
|
| case FIELD:
|
| value = holder->FastPropertyAt(result->GetFieldIndex());
|
| ASSERT(!value->IsTheHole() || result->IsReadOnly());
|
| - return value->IsTheHole() ? Heap::undefined_value() : value;
|
| + return value->IsTheHole() ? heap->undefined_value() : value;
|
| case CONSTANT_FUNCTION:
|
| return result->GetConstantFunction();
|
| case CALLBACKS:
|
| @@ -537,7 +556,7 @@
|
| }
|
|
|
| Object* holder = NULL;
|
| - Context* global_context = Top::context()->global_context();
|
| + Context* global_context = Isolate::Current()->context()->global_context();
|
| if (IsString()) {
|
| holder = global_context->string_function()->instance_prototype();
|
| } else if (IsNumber()) {
|
| @@ -547,7 +566,7 @@
|
| } else {
|
| // Undefined and null have no indexed properties.
|
| ASSERT(IsUndefined() || IsNull());
|
| - return Heap::undefined_value();
|
| + return HEAP->undefined_value();
|
| }
|
|
|
| return JSObject::cast(holder)->GetElementWithReceiver(receiver, index);
|
| @@ -557,14 +576,15 @@
|
| Object* Object::GetPrototype() {
|
| // The object is either a number, a string, a boolean, or a real JS object.
|
| if (IsJSObject()) return JSObject::cast(this)->map()->prototype();
|
| - Context* context = Top::context()->global_context();
|
| + Heap* heap = Isolate::Current()->heap();
|
| + Context* context = heap->isolate()->context()->global_context();
|
|
|
| if (IsNumber()) return context->number_function()->instance_prototype();
|
| if (IsString()) return context->string_function()->instance_prototype();
|
| if (IsBoolean()) {
|
| return context->boolean_function()->instance_prototype();
|
| } else {
|
| - return Heap::null_value();
|
| + return heap->null_value();
|
| }
|
| }
|
|
|
| @@ -638,9 +658,10 @@
|
| // allowed. This is to avoid an assertion failure when allocating.
|
| // Flattening strings is the only case where we always allow
|
| // allocation because no GC is performed if the allocation fails.
|
| - if (!Heap::IsAllocationAllowed()) return this;
|
| + if (!HEAP->IsAllocationAllowed()) return this;
|
| #endif
|
|
|
| + Heap* heap = GetHeap();
|
| switch (StringShape(this).representation_tag()) {
|
| case kConsStringTag: {
|
| ConsString* cs = ConsString::cast(this);
|
| @@ -650,12 +671,12 @@
|
| // There's little point in putting the flat string in new space if the
|
| // cons string is in old space. It can never get GCed until there is
|
| // an old space GC.
|
| - PretenureFlag tenure = Heap::InNewSpace(this) ? pretenure : TENURED;
|
| + PretenureFlag tenure = heap->InNewSpace(this) ? pretenure : TENURED;
|
| int len = length();
|
| Object* object;
|
| String* result;
|
| if (IsAsciiRepresentation()) {
|
| - { MaybeObject* maybe_object = Heap::AllocateRawAsciiString(len, tenure);
|
| + { MaybeObject* maybe_object = heap->AllocateRawAsciiString(len, tenure);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| result = String::cast(object);
|
| @@ -670,7 +691,7 @@
|
| len - first_length);
|
| } else {
|
| { MaybeObject* maybe_object =
|
| - Heap::AllocateRawTwoByteString(len, tenure);
|
| + heap->AllocateRawTwoByteString(len, tenure);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| result = String::cast(object);
|
| @@ -685,7 +706,7 @@
|
| len - first_length);
|
| }
|
| cs->set_first(result);
|
| - cs->set_second(Heap::empty_string());
|
| + cs->set_second(heap->empty_string());
|
| return result;
|
| }
|
| default:
|
| @@ -709,7 +730,7 @@
|
| resource->length() * sizeof(smart_chars[0])) == 0);
|
| }
|
| #endif // DEBUG
|
| -
|
| + Heap* heap = GetHeap();
|
| int size = this->Size(); // Byte size of the original string.
|
| if (size < ExternalString::kSize) {
|
| // The string is too small to fit an external String in its place. This can
|
| @@ -725,8 +746,8 @@
|
| // Morph the object to an external string by adjusting the map and
|
| // reinitializing the fields.
|
| this->set_map(is_ascii ?
|
| - Heap::external_string_with_ascii_data_map() :
|
| - Heap::external_string_map());
|
| + heap->external_string_with_ascii_data_map() :
|
| + heap->external_string_map());
|
| ExternalTwoByteString* self = ExternalTwoByteString::cast(this);
|
| self->set_length(length);
|
| self->set_hash_field(hash_field);
|
| @@ -737,13 +758,13 @@
|
| self->Hash(); // Force regeneration of the hash value.
|
| // Now morph this external string into a external symbol.
|
| this->set_map(is_ascii ?
|
| - Heap::external_symbol_with_ascii_data_map() :
|
| - Heap::external_symbol_map());
|
| + heap->external_symbol_with_ascii_data_map() :
|
| + heap->external_symbol_map());
|
| }
|
|
|
| // Fill the remainder of the string with dead wood.
|
| int new_size = this->Size(); // Byte size of the external String object.
|
| - Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size);
|
| + heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
|
| return true;
|
| }
|
|
|
| @@ -760,7 +781,7 @@
|
| resource->length() * sizeof(smart_chars[0])) == 0);
|
| }
|
| #endif // DEBUG
|
| -
|
| + Heap* heap = GetHeap();
|
| int size = this->Size(); // Byte size of the original string.
|
| if (size < ExternalString::kSize) {
|
| // The string is too small to fit an external String in its place. This can
|
| @@ -774,7 +795,7 @@
|
|
|
| // Morph the object to an external string by adjusting the map and
|
| // reinitializing the fields.
|
| - this->set_map(Heap::external_ascii_string_map());
|
| + this->set_map(heap->external_ascii_string_map());
|
| ExternalAsciiString* self = ExternalAsciiString::cast(this);
|
| self->set_length(length);
|
| self->set_hash_field(hash_field);
|
| @@ -784,12 +805,12 @@
|
| if (is_symbol) {
|
| self->Hash(); // Force regeneration of the hash value.
|
| // Now morph this external string into a external symbol.
|
| - this->set_map(Heap::external_ascii_symbol_map());
|
| + this->set_map(heap->external_ascii_symbol_map());
|
| }
|
|
|
| // Fill the remainder of the string with dead wood.
|
| int new_size = this->Size(); // Byte size of the external String object.
|
| - Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size);
|
| + heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
|
| return true;
|
| }
|
|
|
| @@ -888,15 +909,16 @@
|
| // All other JSObjects are rather similar to each other (JSObject,
|
| // JSGlobalProxy, JSGlobalObject, JSUndetectableObject, JSValue).
|
| default: {
|
| + Heap* heap = GetHeap();
|
| Object* constructor = map()->constructor();
|
| bool printed = false;
|
| if (constructor->IsHeapObject() &&
|
| - !Heap::Contains(HeapObject::cast(constructor))) {
|
| + !heap->Contains(HeapObject::cast(constructor))) {
|
| accumulator->Add("!!!INVALID CONSTRUCTOR!!!");
|
| } else {
|
| bool global_object = IsJSGlobalProxy();
|
| if (constructor->IsJSFunction()) {
|
| - if (!Heap::Contains(JSFunction::cast(constructor)->shared())) {
|
| + if (!heap->Contains(JSFunction::cast(constructor)->shared())) {
|
| accumulator->Add("!!!INVALID SHARED ON CONSTRUCTOR!!!");
|
| } else {
|
| Object* constructor_name =
|
| @@ -931,12 +953,13 @@
|
|
|
|
|
| void HeapObject::HeapObjectShortPrint(StringStream* accumulator) {
|
| - // if (!Heap::InNewSpace(this)) PrintF("*", this);
|
| - if (!Heap::Contains(this)) {
|
| + // if (!HEAP->InNewSpace(this)) PrintF("*", this);
|
| + Heap* heap = GetHeap();
|
| + if (!heap->Contains(this)) {
|
| accumulator->Add("!!!INVALID POINTER!!!");
|
| return;
|
| }
|
| - if (!Heap::Contains(map())) {
|
| + if (!heap->Contains(map())) {
|
| accumulator->Add("!!!INVALID MAP!!!");
|
| return;
|
| }
|
| @@ -1155,14 +1178,14 @@
|
| if (u.bits.exp == 2047) {
|
| // Detect NaN for IEEE double precision floating point.
|
| if ((u.bits.man_low | u.bits.man_high) != 0)
|
| - return Heap::false_value();
|
| + return GetHeap()->false_value();
|
| }
|
| if (u.bits.exp == 0) {
|
| // Detect +0, and -0 for IEEE double precision floating point.
|
| if ((u.bits.man_low | u.bits.man_high) == 0)
|
| - return Heap::false_value();
|
| + return GetHeap()->false_value();
|
| }
|
| - return Heap::true_value();
|
| + return GetHeap()->true_value();
|
| }
|
|
|
|
|
| @@ -1186,14 +1209,14 @@
|
|
|
| String* JSObject::class_name() {
|
| if (IsJSFunction()) {
|
| - return Heap::function_class_symbol();
|
| + return GetHeap()->function_class_symbol();
|
| }
|
| if (map()->constructor()->IsJSFunction()) {
|
| JSFunction* constructor = JSFunction::cast(map()->constructor());
|
| return String::cast(constructor->shared()->instance_class_name());
|
| }
|
| // If the constructor is not present, return "Object".
|
| - return Heap::Object_symbol();
|
| + return GetHeap()->Object_symbol();
|
| }
|
|
|
|
|
| @@ -1208,7 +1231,7 @@
|
| if (proto->IsJSObject()) return JSObject::cast(proto)->constructor_name();
|
| }
|
| // If the constructor is not present, return "Object".
|
| - return Heap::Object_symbol();
|
| + return GetHeap()->Object_symbol();
|
| }
|
|
|
|
|
| @@ -1238,9 +1261,10 @@
|
|
|
| // Normalize the object if the name is an actual string (not the
|
| // hidden symbols) and is not a real identifier.
|
| + Isolate* isolate = GetHeap()->isolate();
|
| StringInputBuffer buffer(name);
|
| - if (!ScannerConstants::IsIdentifier(&buffer)
|
| - && name != Heap::hidden_symbol()) {
|
| + if (!isolate->scanner_constants()->IsIdentifier(&buffer)
|
| + && name != HEAP->hidden_symbol()) {
|
| Object* obj;
|
| { MaybeObject* maybe_obj =
|
| NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
|
| @@ -1267,7 +1291,8 @@
|
| // global object_function's map and there is not a transition for name.
|
| bool allow_map_transition =
|
| !old_descriptors->Contains(name) &&
|
| - (Top::context()->global_context()->object_function()->map() != map());
|
| + (isolate->context()->global_context()->object_function()->
|
| + map() != map());
|
|
|
| ASSERT(index < map()->inobject_properties() ||
|
| (index - map()->inobject_properties()) < properties()->length() ||
|
| @@ -1321,7 +1346,8 @@
|
| String* name,
|
| JSFunction* function,
|
| PropertyAttributes attributes) {
|
| - ASSERT(!Heap::InNewSpace(function));
|
| + Heap* heap = GetHeap();
|
| + ASSERT(!heap->InNewSpace(function));
|
|
|
| // Allocate new instance descriptors with (name, function) added
|
| ConstantFunctionDescriptor d(name, function, attributes);
|
| @@ -1346,7 +1372,8 @@
|
|
|
| // If the old map is the global object map (from new Object()),
|
| // then transitions are not added to it, so we are done.
|
| - if (old_map == Top::context()->global_context()->object_function()->map()) {
|
| + if (old_map == heap->isolate()->context()->global_context()->
|
| + object_function()->map()) {
|
| return function;
|
| }
|
|
|
| @@ -1381,6 +1408,7 @@
|
| Object* value,
|
| PropertyAttributes attributes) {
|
| ASSERT(!HasFastProperties());
|
| + Heap* heap = GetHeap();
|
| StringDictionary* dict = property_dictionary();
|
| Object* store_value = value;
|
| if (IsGlobalObject()) {
|
| @@ -1398,7 +1426,7 @@
|
| return value;
|
| }
|
| { MaybeObject* maybe_store_value =
|
| - Heap::AllocateJSGlobalPropertyCell(value);
|
| + heap->AllocateJSGlobalPropertyCell(value);
|
| if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value;
|
| }
|
| JSGlobalPropertyCell::cast(store_value)->set_value(value);
|
| @@ -1417,16 +1445,17 @@
|
| Object* value,
|
| PropertyAttributes attributes) {
|
| ASSERT(!IsJSGlobalProxy());
|
| + Heap* heap = GetHeap();
|
| if (!map()->is_extensible()) {
|
| Handle<Object> args[1] = {Handle<String>(name)};
|
| - return Top::Throw(*Factory::NewTypeError("object_not_extensible",
|
| - HandleVector(args, 1)));
|
| + return heap->isolate()->Throw(
|
| + *FACTORY->NewTypeError("object_not_extensible", HandleVector(args, 1)));
|
| }
|
| if (HasFastProperties()) {
|
| // Ensure the descriptor array does not get too big.
|
| if (map()->instance_descriptors()->number_of_descriptors() <
|
| DescriptorArray::kMaxNumberOfDescriptors) {
|
| - if (value->IsJSFunction() && !Heap::InNewSpace(value)) {
|
| + if (value->IsJSFunction() && !heap->InNewSpace(value)) {
|
| return AddConstantFunctionProperty(name,
|
| JSFunction::cast(value),
|
| attributes);
|
| @@ -1498,7 +1527,8 @@
|
| return result;
|
| }
|
| // Do not add transitions to the map of "new Object()".
|
| - if (map() == Top::context()->global_context()->object_function()->map()) {
|
| + if (map() == GetHeap()->isolate()->context()->global_context()->
|
| + object_function()->map()) {
|
| return result;
|
| }
|
|
|
| @@ -1585,29 +1615,31 @@
|
| Object* value,
|
| PropertyAttributes attributes,
|
| StrictModeFlag strict_mode) {
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + HandleScope scope(isolate);
|
| Handle<JSObject> this_handle(this);
|
| Handle<String> name_handle(name);
|
| - Handle<Object> value_handle(value);
|
| + Handle<Object> value_handle(value, isolate);
|
| Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
|
| if (!interceptor->setter()->IsUndefined()) {
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-set", this, name));
|
| - CustomArguments args(interceptor->data(), this, this);
|
| + LOG(isolate, ApiNamedPropertyAccess("interceptor-named-set", this, name));
|
| + CustomArguments args(isolate, interceptor->data(), this, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::NamedPropertySetter setter =
|
| v8::ToCData<v8::NamedPropertySetter>(interceptor->setter());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| Handle<Object> value_unhole(value->IsTheHole() ?
|
| - Heap::undefined_value() :
|
| - value);
|
| + isolate->heap()->undefined_value() :
|
| + value,
|
| + isolate);
|
| result = setter(v8::Utils::ToLocal(name_handle),
|
| v8::Utils::ToLocal(value_unhole),
|
| info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) return *value_handle;
|
| }
|
| MaybeObject* raw_result =
|
| @@ -1615,7 +1647,7 @@
|
| *value_handle,
|
| attributes,
|
| strict_mode);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
| @@ -1634,12 +1666,13 @@
|
| String* name,
|
| Object* value,
|
| JSObject* holder) {
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + HandleScope scope(isolate);
|
|
|
| // We should never get here to initialize a const with the hole
|
| // value since a const declaration would conflict with the setter.
|
| ASSERT(!value->IsTheHole());
|
| - Handle<Object> value_handle(value);
|
| + Handle<Object> value_handle(value, isolate);
|
|
|
| // To accommodate both the old and the new api we switch on the
|
| // data structure used to store the callbacks. Eventually proxy
|
| @@ -1648,7 +1681,7 @@
|
| AccessorDescriptor* callback =
|
| reinterpret_cast<AccessorDescriptor*>(Proxy::cast(structure)->proxy());
|
| MaybeObject* obj = (callback->setter)(this, value, callback->data);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (obj->IsFailure()) return obj;
|
| return *value_handle;
|
| }
|
| @@ -1660,17 +1693,17 @@
|
| v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj);
|
| if (call_fun == NULL) return value;
|
| Handle<String> key(name);
|
| - LOG(ApiNamedPropertyAccess("store", this, name));
|
| - CustomArguments args(data->data(), this, JSObject::cast(holder));
|
| + LOG(isolate, ApiNamedPropertyAccess("store", this, name));
|
| + CustomArguments args(isolate, data->data(), this, JSObject::cast(holder));
|
| v8::AccessorInfo info(args.end());
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| call_fun(v8::Utils::ToLocal(key),
|
| v8::Utils::ToLocal(value_handle),
|
| info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return *value_handle;
|
| }
|
|
|
| @@ -1680,10 +1713,11 @@
|
| return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value);
|
| } else {
|
| Handle<String> key(name);
|
| - Handle<Object> holder_handle(holder);
|
| + Handle<Object> holder_handle(holder, isolate);
|
| Handle<Object> args[2] = { key, holder_handle };
|
| - return Top::Throw(*Factory::NewTypeError("no_setter_in_callback",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(
|
| + *isolate->factory()->NewTypeError("no_setter_in_callback",
|
| + HandleVector(args, 2)));
|
| }
|
| }
|
|
|
| @@ -1694,13 +1728,15 @@
|
|
|
| MaybeObject* JSObject::SetPropertyWithDefinedSetter(JSFunction* setter,
|
| Object* value) {
|
| - Handle<Object> value_handle(value);
|
| - Handle<JSFunction> fun(JSFunction::cast(setter));
|
| - Handle<JSObject> self(this);
|
| + Isolate* isolate = GetIsolate();
|
| + Handle<Object> value_handle(value, isolate);
|
| + Handle<JSFunction> fun(JSFunction::cast(setter), isolate);
|
| + Handle<JSObject> self(this, isolate);
|
| #ifdef ENABLE_DEBUGGER_SUPPORT
|
| + Debug* debug = isolate->debug();
|
| // Handle stepping into a setter if step into is active.
|
| - if (Debug::StepInActive()) {
|
| - Debug::HandleStepIn(fun, Handle<Object>::null(), 0, false);
|
| + if (debug->StepInActive()) {
|
| + debug->HandleStepIn(fun, Handle<Object>::null(), 0, false);
|
| }
|
| #endif
|
| bool has_pending_exception;
|
| @@ -1714,8 +1750,9 @@
|
|
|
| void JSObject::LookupCallbackSetterInPrototypes(String* name,
|
| LookupResult* result) {
|
| + Heap* heap = GetHeap();
|
| for (Object* pt = GetPrototype();
|
| - pt != Heap::null_value();
|
| + pt != heap->null_value();
|
| pt = pt->GetPrototype()) {
|
| JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result);
|
| if (result->IsProperty()) {
|
| @@ -1735,8 +1772,9 @@
|
| MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index,
|
| Object* value,
|
| bool* found) {
|
| + Heap* heap = GetHeap();
|
| for (Object* pt = GetPrototype();
|
| - pt != Heap::null_value();
|
| + pt != heap->null_value();
|
| pt = pt->GetPrototype()) {
|
| if (!JSObject::cast(pt)->HasDictionaryElements()) {
|
| continue;
|
| @@ -1753,7 +1791,7 @@
|
| }
|
| }
|
| *found = false;
|
| - return Heap::the_hole_value();
|
| + return heap->the_hole_value();
|
| }
|
|
|
|
|
| @@ -1772,10 +1810,11 @@
|
| String* name,
|
| LookupResult* result) {
|
| DescriptorArray* descriptors = instance_descriptors();
|
| - int number = DescriptorLookupCache::Lookup(descriptors, name);
|
| + DescriptorLookupCache* cache = heap()->isolate()->descriptor_lookup_cache();
|
| + int number = cache->Lookup(descriptors, name);
|
| if (number == DescriptorLookupCache::kAbsent) {
|
| number = descriptors->Search(name);
|
| - DescriptorLookupCache::Update(descriptors, name, number);
|
| + cache->Update(descriptors, name, number);
|
| }
|
| if (number != DescriptorArray::kNotFound) {
|
| result->DescriptorResult(holder, descriptors->GetDetails(number), number);
|
| @@ -1843,8 +1882,9 @@
|
|
|
| void JSObject::LookupRealNamedPropertyInPrototypes(String* name,
|
| LookupResult* result) {
|
| + Heap* heap = GetHeap();
|
| for (Object* pt = GetPrototype();
|
| - pt != Heap::null_value();
|
| + pt != heap->null_value();
|
| pt = JSObject::cast(pt)->GetPrototype()) {
|
| JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result);
|
| if (result->IsProperty() && (result->type() != INTERCEPTOR)) return;
|
| @@ -1858,6 +1898,7 @@
|
| String* name,
|
| Object* value,
|
| bool check_prototype) {
|
| + Heap* heap = GetHeap();
|
| if (check_prototype && !result->IsProperty()) {
|
| LookupCallbackSetterInPrototypes(name, result);
|
| }
|
| @@ -1898,7 +1939,7 @@
|
|
|
| HandleScope scope;
|
| Handle<Object> value_handle(value);
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| return *value_handle;
|
| }
|
|
|
| @@ -1908,6 +1949,7 @@
|
| Object* value,
|
| PropertyAttributes attributes,
|
| StrictModeFlag strict_mode) {
|
| + Heap* heap = GetHeap();
|
| // Make sure that the top context does not change when doing callbacks or
|
| // interceptor calls.
|
| AssertNoContextChange ncc;
|
| @@ -1917,7 +1959,7 @@
|
| // reallocating them.
|
| if (!name->IsSymbol() && name->length() <= 2) {
|
| Object* symbol_version;
|
| - { MaybeObject* maybe_symbol_version = Heap::LookupSymbol(name);
|
| + { MaybeObject* maybe_symbol_version = heap->LookupSymbol(name);
|
| if (maybe_symbol_version->ToObject(&symbol_version)) {
|
| name = String::cast(symbol_version);
|
| }
|
| @@ -1926,7 +1968,7 @@
|
|
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded()
|
| - && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| + && !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| return SetPropertyWithFailedAccessCheck(result, name, value, true);
|
| }
|
|
|
| @@ -1960,8 +2002,8 @@
|
| Handle<String> key(name);
|
| Handle<Object> holder(this);
|
| Handle<Object> args[2] = { key, holder };
|
| - return Top::Throw(*Factory::NewTypeError("strict_read_only_property",
|
| - HandleVector(args, 2)));
|
| + return heap->isolate()->Throw(*heap->isolate()->factory()->NewTypeError(
|
| + "strict_read_only_property", HandleVector(args, 2)));
|
| } else {
|
| return value;
|
| }
|
| @@ -2004,7 +2046,7 @@
|
| ASSERT(target_descriptors->GetType(number) == CONSTANT_FUNCTION);
|
| JSFunction* function =
|
| JSFunction::cast(target_descriptors->GetValue(number));
|
| - ASSERT(!Heap::InNewSpace(function));
|
| + ASSERT(!HEAP->InNewSpace(function));
|
| if (value == function) {
|
| set_map(target_map);
|
| return value;
|
| @@ -2033,6 +2075,8 @@
|
| String* name,
|
| Object* value,
|
| PropertyAttributes attributes) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Make sure that the top context does not change when doing callbacks or
|
| // interceptor calls.
|
| AssertNoContextChange ncc;
|
| @@ -2040,7 +2084,7 @@
|
| LocalLookup(name, &result);
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded()
|
| - && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| + && !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| return SetPropertyWithFailedAccessCheck(&result, name, value, false);
|
| }
|
|
|
| @@ -2112,7 +2156,7 @@
|
| if (continue_search) {
|
| // Continue searching via the prototype chain.
|
| Object* pt = GetPrototype();
|
| - if (pt != Heap::null_value()) {
|
| + if (!pt->IsNull()) {
|
| return JSObject::cast(pt)->
|
| GetPropertyAttributeWithReceiver(receiver, name);
|
| }
|
| @@ -2125,25 +2169,28 @@
|
| JSObject* receiver,
|
| String* name,
|
| bool continue_search) {
|
| + Isolate* isolate = GetIsolate();
|
| +
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
|
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
|
| Handle<JSObject> receiver_handle(receiver);
|
| Handle<JSObject> holder_handle(this);
|
| Handle<String> name_handle(name);
|
| - CustomArguments args(interceptor->data(), receiver, this);
|
| + CustomArguments args(isolate, interceptor->data(), receiver, this);
|
| v8::AccessorInfo info(args.end());
|
| if (!interceptor->query()->IsUndefined()) {
|
| v8::NamedPropertyQuery query =
|
| v8::ToCData<v8::NamedPropertyQuery>(interceptor->query());
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-has", *holder_handle, name));
|
| + LOG(isolate,
|
| + ApiNamedPropertyAccess("interceptor-named-has", *holder_handle, name));
|
| v8::Handle<v8::Integer> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = query(v8::Utils::ToLocal(name_handle), info);
|
| }
|
| if (!result.IsEmpty()) {
|
| @@ -2153,11 +2200,12 @@
|
| } else if (!interceptor->getter()->IsUndefined()) {
|
| v8::NamedPropertyGetter getter =
|
| v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-get-has", this, name));
|
| + LOG(isolate,
|
| + ApiNamedPropertyAccess("interceptor-named-get-has", this, name));
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = getter(v8::Utils::ToLocal(name_handle), info);
|
| }
|
| if (!result.IsEmpty()) return DONT_ENUM;
|
| @@ -2187,9 +2235,10 @@
|
| LookupResult* result,
|
| String* name,
|
| bool continue_search) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) {
|
| + !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
|
| return GetPropertyAttributeWithFailedAccessCheck(receiver,
|
| result,
|
| name,
|
| @@ -2255,7 +2304,7 @@
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| set(index, result);
|
| - Counters::normalized_maps.Increment();
|
| + COUNTERS->normalized_maps()->Increment();
|
|
|
| return result;
|
| }
|
| @@ -2315,7 +2364,7 @@
|
| UNIQUE_NORMALIZED_MAP);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| - Counters::normalized_maps.Increment();
|
| + COUNTERS->normalized_maps()->Increment();
|
|
|
| set_map(Map::cast(obj));
|
| }
|
| @@ -2329,10 +2378,11 @@
|
|
|
| // The global object is always normalized.
|
| ASSERT(!IsGlobalObject());
|
| -
|
| // JSGlobalProxy must never be normalized
|
| ASSERT(!IsJSGlobalProxy());
|
|
|
| + Heap* heap = GetHeap();
|
| +
|
| // Allocate new content.
|
| int property_count = map()->NumberOfDescribedProperties();
|
| if (expected_additional_properties > 0) {
|
| @@ -2401,8 +2451,8 @@
|
| int index = map()->instance_descriptors()->NextEnumerationIndex();
|
| dictionary->SetNextEnumerationIndex(index);
|
|
|
| - { MaybeObject* maybe_obj = Top::context()->global_context()->
|
| - normalized_map_cache()->Get(this, mode);
|
| + { MaybeObject* maybe_obj = heap->isolate()->context()->global_context()->
|
| + normalized_map_cache()->Get(this, mode);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| Map* new_map = Map::cast(obj);
|
| @@ -2414,14 +2464,15 @@
|
| int new_instance_size = new_map->instance_size();
|
| int instance_size_delta = map()->instance_size() - new_instance_size;
|
| ASSERT(instance_size_delta >= 0);
|
| - Heap::CreateFillerObjectAt(this->address() + new_instance_size,
|
| + heap->CreateFillerObjectAt(this->address() + new_instance_size,
|
| instance_size_delta);
|
|
|
| set_map(new_map);
|
| + map()->set_instance_descriptors(heap->empty_descriptor_array());
|
|
|
| set_properties(dictionary);
|
|
|
| - Counters::props_to_dictionary.Increment();
|
| + heap->isolate()->counters()->props_to_dictionary()->Increment();
|
|
|
| #ifdef DEBUG
|
| if (FLAG_trace_normalization) {
|
| @@ -2482,7 +2533,8 @@
|
| set_map(new_map);
|
| set_elements(dictionary);
|
|
|
| - Counters::elements_to_dictionary.Increment();
|
| + new_map->GetHeap()->isolate()->counters()->elements_to_dictionary()->
|
| + Increment();
|
|
|
| #ifdef DEBUG
|
| if (FLAG_trace_normalization) {
|
| @@ -2498,9 +2550,10 @@
|
| MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name,
|
| DeleteMode mode) {
|
| // Check local property, ignore interceptor.
|
| + Heap* heap = GetHeap();
|
| LookupResult result;
|
| LocalLookupRealNamedProperty(name, &result);
|
| - if (!result.IsProperty()) return Heap::true_value();
|
| + if (!result.IsProperty()) return heap->true_value();
|
|
|
| // Normalize object if needed.
|
| Object* obj;
|
| @@ -2513,23 +2566,25 @@
|
|
|
|
|
| MaybeObject* JSObject::DeletePropertyWithInterceptor(String* name) {
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
|
| Handle<String> name_handle(name);
|
| Handle<JSObject> this_handle(this);
|
| if (!interceptor->deleter()->IsUndefined()) {
|
| v8::NamedPropertyDeleter deleter =
|
| v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter());
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name));
|
| - CustomArguments args(interceptor->data(), this, this);
|
| + LOG(isolate,
|
| + ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name));
|
| + CustomArguments args(isolate, interceptor->data(), this, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Boolean> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = deleter(v8::Utils::ToLocal(name_handle), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) {
|
| ASSERT(result->IsBoolean());
|
| return *v8::Utils::OpenHandle(*result);
|
| @@ -2537,13 +2592,14 @@
|
| }
|
| MaybeObject* raw_result =
|
| this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
|
|
| MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index,
|
| DeleteMode mode) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(!HasExternalArrayElements());
|
| switch (GetElementsKind()) {
|
| case FAST_ELEMENTS: {
|
| @@ -2571,52 +2627,56 @@
|
| UNREACHABLE();
|
| break;
|
| }
|
| - return Heap::true_value();
|
| + return heap->true_value();
|
| }
|
|
|
|
|
| MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) {
|
| + Isolate* isolate = GetIsolate();
|
| + Heap* heap = isolate->heap();
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
|
| - if (interceptor->deleter()->IsUndefined()) return Heap::false_value();
|
| + if (interceptor->deleter()->IsUndefined()) return heap->false_value();
|
| v8::IndexedPropertyDeleter deleter =
|
| v8::ToCData<v8::IndexedPropertyDeleter>(interceptor->deleter());
|
| Handle<JSObject> this_handle(this);
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-delete", this, index));
|
| - CustomArguments args(interceptor->data(), this, this);
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-delete", this, index));
|
| + CustomArguments args(isolate, interceptor->data(), this, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Boolean> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = deleter(index, info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) {
|
| ASSERT(result->IsBoolean());
|
| return *v8::Utils::OpenHandle(*result);
|
| }
|
| MaybeObject* raw_result =
|
| this_handle->DeleteElementPostInterceptor(index, NORMAL_DELETION);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
|
|
| MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
|
| + Isolate* isolate = GetIsolate();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
|
| - return Heap::false_value();
|
| + !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| Object* proto = GetPrototype();
|
| - if (proto->IsNull()) return Heap::false_value();
|
| + if (proto->IsNull()) return isolate->heap()->false_value();
|
| ASSERT(proto->IsJSGlobalObject());
|
| return JSGlobalObject::cast(proto)->DeleteElement(index, mode);
|
| }
|
| @@ -2659,15 +2719,16 @@
|
| int entry = dictionary->FindEntry(index);
|
| if (entry != NumberDictionary::kNotFound) {
|
| Object* result = dictionary->DeleteProperty(entry, mode);
|
| - if (mode == STRICT_DELETION && result == Heap::false_value()) {
|
| + if (mode == STRICT_DELETION && result ==
|
| + isolate->heap()->false_value()) {
|
| // In strict mode, deleting a non-configurable property throws
|
| // exception. dictionary->DeleteProperty will return false_value()
|
| // if a non-configurable property is being deleted.
|
| HandleScope scope;
|
| - Handle<Object> i = Factory::NewNumberFromUint(index);
|
| + Handle<Object> i = isolate->factory()->NewNumberFromUint(index);
|
| Handle<Object> args[2] = { i, Handle<Object>(this) };
|
| - return Top::Throw(*Factory::NewTypeError("strict_delete_property",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(*isolate->factory()->NewTypeError(
|
| + "strict_delete_property", HandleVector(args, 2)));
|
| }
|
| }
|
| break;
|
| @@ -2676,24 +2737,25 @@
|
| UNREACHABLE();
|
| break;
|
| }
|
| - return Heap::true_value();
|
| + return isolate->heap()->true_value();
|
| }
|
|
|
|
|
| MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) {
|
| + Isolate* isolate = GetIsolate();
|
| // ECMA-262, 3rd, 8.6.2.5
|
| ASSERT(name->IsString());
|
|
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
|
| - return Heap::false_value();
|
| + !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| Object* proto = GetPrototype();
|
| - if (proto->IsNull()) return Heap::false_value();
|
| + if (proto->IsNull()) return isolate->heap()->false_value();
|
| ASSERT(proto->IsJSGlobalObject());
|
| return JSGlobalObject::cast(proto)->DeleteProperty(name, mode);
|
| }
|
| @@ -2704,17 +2766,17 @@
|
| } else {
|
| LookupResult result;
|
| LocalLookup(name, &result);
|
| - if (!result.IsProperty()) return Heap::true_value();
|
| + if (!result.IsProperty()) return isolate->heap()->true_value();
|
| // Ignore attributes if forcing a deletion.
|
| if (result.IsDontDelete() && mode != FORCE_DELETION) {
|
| if (mode == STRICT_DELETION) {
|
| // Deleting a non-configurable property in strict mode.
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) };
|
| - return Top::Throw(*Factory::NewTypeError("strict_delete_property",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(*isolate->factory()->NewTypeError(
|
| + "strict_delete_property", HandleVector(args, 2)));
|
| }
|
| - return Heap::false_value();
|
| + return isolate->heap()->false_value();
|
| }
|
| // Check for interceptor.
|
| if (result.type() == INTERCEPTOR) {
|
| @@ -2738,6 +2800,7 @@
|
|
|
| // Check whether this object references another object.
|
| bool JSObject::ReferencesObject(Object* obj) {
|
| + Heap* heap = GetHeap();
|
| AssertNoAllocation no_alloc;
|
|
|
| // Is the object the constructor for this object?
|
| @@ -2752,7 +2815,7 @@
|
|
|
| // Check if the object is among the named properties.
|
| Object* key = SlowReverseLookup(obj);
|
| - if (key != Heap::undefined_value()) {
|
| + if (!key->IsUndefined()) {
|
| return true;
|
| }
|
|
|
| @@ -2783,7 +2846,7 @@
|
| }
|
| case DICTIONARY_ELEMENTS: {
|
| key = element_dictionary()->SlowReverseLookup(obj);
|
| - if (key != Heap::undefined_value()) {
|
| + if (!key->IsUndefined()) {
|
| return true;
|
| }
|
| break;
|
| @@ -2797,7 +2860,8 @@
|
| if (IsJSFunction()) {
|
| // Get the constructor function for arguments array.
|
| JSObject* arguments_boilerplate =
|
| - Top::context()->global_context()->arguments_boilerplate();
|
| + heap->isolate()->context()->global_context()->
|
| + arguments_boilerplate();
|
| JSFunction* arguments_function =
|
| JSFunction::cast(arguments_boilerplate->map()->constructor());
|
|
|
| @@ -2836,10 +2900,13 @@
|
|
|
|
|
| MaybeObject* JSObject::PreventExtensions() {
|
| + Isolate* isolate = GetIsolate();
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, Heap::undefined_value(), v8::ACCESS_KEYS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
|
| - return Heap::false_value();
|
| + !isolate->MayNamedAccess(this,
|
| + isolate->heap()->undefined_value(),
|
| + v8::ACCESS_KEYS)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| @@ -2878,8 +2945,9 @@
|
| // - This object has no elements.
|
| // - No prototype has enumerable properties/elements.
|
| bool JSObject::IsSimpleEnum() {
|
| + Heap* heap = GetHeap();
|
| for (Object* o = this;
|
| - o != Heap::null_value();
|
| + o != heap->null_value();
|
| o = JSObject::cast(o)->GetPrototype()) {
|
| JSObject* curr = JSObject::cast(o);
|
| if (!curr->map()->instance_descriptors()->HasEnumCache()) return false;
|
| @@ -2945,6 +3013,8 @@
|
| void JSObject::LocalLookup(String* name, LookupResult* result) {
|
| ASSERT(name->IsString());
|
|
|
| + Heap* heap = GetHeap();
|
| +
|
| if (IsJSGlobalProxy()) {
|
| Object* proto = GetPrototype();
|
| if (proto->IsNull()) return result->NotFound();
|
| @@ -2959,13 +3029,14 @@
|
| }
|
|
|
| // Check __proto__ before interceptor.
|
| - if (name->Equals(Heap::Proto_symbol()) && !IsJSContextExtensionObject()) {
|
| + if (name->Equals(heap->Proto_symbol()) &&
|
| + !IsJSContextExtensionObject()) {
|
| result->ConstantResult(this);
|
| return;
|
| }
|
|
|
| // Check for lookup interceptor except when bootstrapping.
|
| - if (HasNamedInterceptor() && !Bootstrapper::IsActive()) {
|
| + if (HasNamedInterceptor() && !heap->isolate()->bootstrapper()->IsActive()) {
|
| result->InterceptorResult(this);
|
| return;
|
| }
|
| @@ -2976,8 +3047,9 @@
|
|
|
| void JSObject::Lookup(String* name, LookupResult* result) {
|
| // Ecma-262 3rd 8.6.2.4
|
| + Heap* heap = GetHeap();
|
| for (Object* current = this;
|
| - current != Heap::null_value();
|
| + current != heap->null_value();
|
| current = JSObject::cast(current)->GetPrototype()) {
|
| JSObject::cast(current)->LocalLookup(name, result);
|
| if (result->IsProperty()) return;
|
| @@ -2988,8 +3060,9 @@
|
|
|
| // Search object and it's prototype chain for callback properties.
|
| void JSObject::LookupCallback(String* name, LookupResult* result) {
|
| + Heap* heap = GetHeap();
|
| for (Object* current = this;
|
| - current != Heap::null_value();
|
| + current != heap->null_value();
|
| current = JSObject::cast(current)->GetPrototype()) {
|
| JSObject::cast(current)->LocalLookupRealNamedProperty(name, result);
|
| if (result->IsProperty() && result->type() == CALLBACKS) return;
|
| @@ -3000,6 +3073,7 @@
|
|
|
| MaybeObject* JSObject::DefineGetterSetter(String* name,
|
| PropertyAttributes attributes) {
|
| + Heap* heap = GetHeap();
|
| // Make sure that the top context does not change when doing callbacks or
|
| // interceptor calls.
|
| AssertNoContextChange ncc;
|
| @@ -3008,7 +3082,7 @@
|
| name->TryFlatten();
|
|
|
| if (!CanSetCallback(name)) {
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
| uint32_t index = 0;
|
| @@ -3028,7 +3102,7 @@
|
| case EXTERNAL_FLOAT_ELEMENTS:
|
| // Ignore getters and setters on pixel and external array
|
| // elements.
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| case DICTIONARY_ELEMENTS: {
|
| // Lookup the index.
|
| NumberDictionary* dictionary = element_dictionary();
|
| @@ -3036,7 +3110,7 @@
|
| if (entry != NumberDictionary::kNotFound) {
|
| Object* result = dictionary->ValueAt(entry);
|
| PropertyDetails details = dictionary->DetailsAt(entry);
|
| - if (details.IsReadOnly()) return Heap::undefined_value();
|
| + if (details.IsReadOnly()) return heap->undefined_value();
|
| if (details.type() == CALLBACKS) {
|
| if (result->IsFixedArray()) {
|
| return result;
|
| @@ -3055,7 +3129,7 @@
|
| LookupResult result;
|
| LocalLookup(name, &result);
|
| if (result.IsProperty()) {
|
| - if (result.IsReadOnly()) return Heap::undefined_value();
|
| + if (result.IsReadOnly()) return heap->undefined_value();
|
| if (result.type() == CALLBACKS) {
|
| Object* obj = result.GetCallbackObject();
|
| // Need to preserve old getters/setters.
|
| @@ -3069,7 +3143,7 @@
|
|
|
| // Allocate the fixed array to hold getter and setter.
|
| Object* structure;
|
| - { MaybeObject* maybe_structure = Heap::AllocateFixedArray(2, TENURED);
|
| + { MaybeObject* maybe_structure = heap->AllocateFixedArray(2, TENURED);
|
| if (!maybe_structure->ToObject(&structure)) return maybe_structure;
|
| }
|
|
|
| @@ -3083,7 +3157,7 @@
|
|
|
| bool JSObject::CanSetCallback(String* name) {
|
| ASSERT(!IsAccessCheckNeeded()
|
| - || Top::MayNamedAccess(this, name, v8::ACCESS_SET));
|
| + || Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET));
|
|
|
| // Check if there is an API defined callback object which prohibits
|
| // callback overwriting in this object or it's prototype chain.
|
| @@ -3180,11 +3254,12 @@
|
| Object* fun,
|
| PropertyAttributes attributes) {
|
| ASSERT(fun->IsJSFunction() || fun->IsUndefined());
|
| + Isolate* isolate = GetIsolate();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| - return Heap::undefined_value();
|
| + !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| @@ -3206,12 +3281,13 @@
|
|
|
|
|
| MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
|
| + Isolate* isolate = GetIsolate();
|
| String* name = String::cast(info->name());
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| - return Heap::undefined_value();
|
| + !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| @@ -3229,14 +3305,14 @@
|
| name->TryFlatten();
|
|
|
| if (!CanSetCallback(name)) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| uint32_t index = 0;
|
| bool is_element = name->AsArrayIndex(&index);
|
|
|
| if (is_element) {
|
| - if (IsJSArray()) return Heap::undefined_value();
|
| + if (IsJSArray()) return isolate->heap()->undefined_value();
|
|
|
| // Accessors overwrite previous callbacks (cf. with getters/setters).
|
| switch (GetElementsKind()) {
|
| @@ -3252,7 +3328,7 @@
|
| case EXTERNAL_FLOAT_ELEMENTS:
|
| // Ignore getters and setters on pixel and external array
|
| // elements.
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| case DICTIONARY_ELEMENTS:
|
| break;
|
| default:
|
| @@ -3272,7 +3348,7 @@
|
| // ES5 forbids turning a property into an accessor if it's not
|
| // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5).
|
| if (result.IsProperty() && (result.IsReadOnly() || result.IsDontDelete())) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
| Object* ok;
|
| { MaybeObject* maybe_ok =
|
| @@ -3286,15 +3362,17 @@
|
|
|
|
|
| Object* JSObject::LookupAccessor(String* name, bool is_getter) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Make sure that the top context does not change when doing callbacks or
|
| // interceptor calls.
|
| AssertNoContextChange ncc;
|
|
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| - return Heap::undefined_value();
|
| + !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + return heap->undefined_value();
|
| }
|
|
|
| // Make the lookup and include prototypes.
|
| @@ -3302,7 +3380,7 @@
|
| uint32_t index = 0;
|
| if (name->AsArrayIndex(&index)) {
|
| for (Object* obj = this;
|
| - obj != Heap::null_value();
|
| + obj != heap->null_value();
|
| obj = JSObject::cast(obj)->GetPrototype()) {
|
| JSObject* js_object = JSObject::cast(obj);
|
| if (js_object->HasDictionaryElements()) {
|
| @@ -3321,12 +3399,12 @@
|
| }
|
| } else {
|
| for (Object* obj = this;
|
| - obj != Heap::null_value();
|
| + obj != heap->null_value();
|
| obj = JSObject::cast(obj)->GetPrototype()) {
|
| LookupResult result;
|
| JSObject::cast(obj)->LocalLookup(name, &result);
|
| if (result.IsProperty()) {
|
| - if (result.IsReadOnly()) return Heap::undefined_value();
|
| + if (result.IsReadOnly()) return heap->undefined_value();
|
| if (result.type() == CALLBACKS) {
|
| Object* obj = result.GetCallbackObject();
|
| if (obj->IsFixedArray()) {
|
| @@ -3336,11 +3414,12 @@
|
| }
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| Object* JSObject::SlowReverseLookup(Object* value) {
|
| + Heap* heap = GetHeap();
|
| if (HasFastProperties()) {
|
| DescriptorArray* descs = map()->instance_descriptors();
|
| for (int i = 0; i < descs->number_of_descriptors(); i++) {
|
| @@ -3354,7 +3433,7 @@
|
| }
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| } else {
|
| return property_dictionary()->SlowReverseLookup(value);
|
| }
|
| @@ -3362,9 +3441,10 @@
|
|
|
|
|
| MaybeObject* Map::CopyDropDescriptors() {
|
| + Heap* heap = GetHeap();
|
| Object* result;
|
| { MaybeObject* maybe_result =
|
| - Heap::AllocateMap(instance_type(), instance_size());
|
| + heap->AllocateMap(instance_type(), instance_size());
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| Map::cast(result)->set_prototype(prototype());
|
| @@ -3374,7 +3454,8 @@
|
| // pointing to the same transition which is bad because the garbage
|
| // collector relies on being able to reverse pointers from transitions
|
| // to maps. If properties need to be retained use CopyDropTransitions.
|
| - Map::cast(result)->set_instance_descriptors(Heap::empty_descriptor_array());
|
| + Map::cast(result)->set_instance_descriptors(
|
| + heap->empty_descriptor_array());
|
| // Please note instance_type and instance_size are set when allocated.
|
| Map::cast(result)->set_inobject_properties(inobject_properties());
|
| Map::cast(result)->set_unused_property_fields(unused_property_fields());
|
| @@ -3397,7 +3478,7 @@
|
| Map::cast(result)->set_bit_field(bit_field());
|
| Map::cast(result)->set_bit_field2(bit_field2());
|
| Map::cast(result)->set_is_shared(false);
|
| - Map::cast(result)->ClearCodeCache();
|
| + Map::cast(result)->ClearCodeCache(heap);
|
| return result;
|
| }
|
|
|
| @@ -3411,7 +3492,7 @@
|
|
|
| Object* result;
|
| { MaybeObject* maybe_result =
|
| - Heap::AllocateMap(instance_type(), new_instance_size);
|
| + GetHeap()->AllocateMap(instance_type(), new_instance_size);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
|
|
| @@ -3456,7 +3537,7 @@
|
| // Allocate the code cache if not present.
|
| if (code_cache()->IsFixedArray()) {
|
| Object* result;
|
| - { MaybeObject* maybe_result = Heap::AllocateCodeCache();
|
| + { MaybeObject* maybe_result = GetHeap()->AllocateCodeCache();
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| set_code_cache(result);
|
| @@ -3472,7 +3553,7 @@
|
| if (!code_cache()->IsFixedArray()) {
|
| return CodeCache::cast(code_cache())->Lookup(name, flags);
|
| } else {
|
| - return Heap::undefined_value();
|
| + return GetHeap()->undefined_value();
|
| }
|
| }
|
|
|
| @@ -3496,12 +3577,13 @@
|
|
|
| void Map::TraverseTransitionTree(TraverseCallback callback, void* data) {
|
| Map* current = this;
|
| - while (current != Heap::meta_map()) {
|
| + Map* meta_map = heap()->meta_map();
|
| + while (current != meta_map) {
|
| DescriptorArray* d = reinterpret_cast<DescriptorArray*>(
|
| *RawField(current, Map::kInstanceDescriptorsOffset));
|
| - if (d == Heap::empty_descriptor_array()) {
|
| + if (d == heap()->empty_descriptor_array()) {
|
| Map* prev = current->map();
|
| - current->set_map(Heap::meta_map());
|
| + current->set_map(meta_map);
|
| callback(current, data);
|
| current = prev;
|
| continue;
|
| @@ -3526,9 +3608,9 @@
|
| }
|
| }
|
| if (!map_done) continue;
|
| - *map_or_index_field = Heap::fixed_array_map();
|
| + *map_or_index_field = heap()->fixed_array_map();
|
| Map* prev = current->map();
|
| - current->set_map(Heap::meta_map());
|
| + current->set_map(meta_map);
|
| callback(current, data);
|
| current = prev;
|
| }
|
| @@ -3641,6 +3723,7 @@
|
|
|
|
|
| Object* CodeCache::LookupDefaultCache(String* name, Code::Flags flags) {
|
| + Heap* heap = GetHeap();
|
| FixedArray* cache = default_cache();
|
| int length = cache->length();
|
| for (int i = 0; i < length; i += kCodeCacheEntrySize) {
|
| @@ -3655,7 +3738,7 @@
|
| }
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| @@ -3664,7 +3747,7 @@
|
| CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache());
|
| return cache->Lookup(name, flags);
|
| } else {
|
| - return Heap::undefined_value();
|
| + return GetHeap()->undefined_value();
|
| }
|
| }
|
|
|
| @@ -3746,7 +3829,7 @@
|
| MUST_USE_RESULT MaybeObject* AsObject() {
|
| ASSERT(code_ != NULL);
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(2);
|
| + { MaybeObject* maybe_obj = code_->GetHeap()->AllocateFixedArray(2);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* pair = FixedArray::cast(obj);
|
| @@ -3765,7 +3848,7 @@
|
| Object* CodeCacheHashTable::Lookup(String* name, Code::Flags flags) {
|
| CodeCacheHashTableKey key(name, flags);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return GetHeap()->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
| @@ -3802,8 +3885,9 @@
|
|
|
| void CodeCacheHashTable::RemoveByIndex(int index) {
|
| ASSERT(index >= 0);
|
| - set(EntryToIndex(index), Heap::null_value());
|
| - set(EntryToIndex(index) + 1, Heap::null_value());
|
| + Heap* heap = GetHeap();
|
| + set(EntryToIndex(index), heap->null_value());
|
| + set(EntryToIndex(index) + 1, heap->null_value());
|
| ElementRemoved();
|
| }
|
|
|
| @@ -3823,6 +3907,7 @@
|
|
|
|
|
| MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(!array->HasExternalArrayElements());
|
| switch (array->GetElementsKind()) {
|
| case JSObject::FAST_ELEMENTS:
|
| @@ -3833,7 +3918,7 @@
|
|
|
| // Allocate a temporary fixed array.
|
| Object* object;
|
| - { MaybeObject* maybe_object = Heap::AllocateFixedArray(size);
|
| + { MaybeObject* maybe_object = heap->AllocateFixedArray(size);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| FixedArray* key_array = FixedArray::cast(object);
|
| @@ -3853,11 +3938,12 @@
|
| UNREACHABLE();
|
| }
|
| UNREACHABLE();
|
| - return Heap::null_value(); // Failure case needs to "return" a value.
|
| + return heap->null_value(); // Failure case needs to "return" a value.
|
| }
|
|
|
|
|
| MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) {
|
| + Heap* heap = GetHeap();
|
| int len0 = length();
|
| #ifdef DEBUG
|
| if (FLAG_enable_slow_asserts) {
|
| @@ -3883,7 +3969,7 @@
|
|
|
| // Allocate the result
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(len0 + extra);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(len0 + extra);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| // Fill in the content
|
| @@ -3912,9 +3998,10 @@
|
|
|
|
|
| MaybeObject* FixedArray::CopySize(int new_length) {
|
| - if (new_length == 0) return Heap::empty_fixed_array();
|
| + Heap* heap = GetHeap();
|
| + if (new_length == 0) return heap->empty_fixed_array();
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(new_length);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* result = FixedArray::cast(obj);
|
| @@ -3952,13 +4039,14 @@
|
|
|
|
|
| MaybeObject* DescriptorArray::Allocate(int number_of_descriptors) {
|
| + Heap* heap = Isolate::Current()->heap();
|
| if (number_of_descriptors == 0) {
|
| - return Heap::empty_descriptor_array();
|
| + return heap->empty_descriptor_array();
|
| }
|
| // Allocate the array of keys.
|
| Object* array;
|
| { MaybeObject* maybe_array =
|
| - Heap::AllocateFixedArray(ToKeyIndex(number_of_descriptors));
|
| + heap->AllocateFixedArray(ToKeyIndex(number_of_descriptors));
|
| if (!maybe_array->ToObject(&array)) return maybe_array;
|
| }
|
| // Do not use DescriptorArray::cast on incomplete object.
|
| @@ -3966,7 +4054,7 @@
|
|
|
| // Allocate the content array and set it in the descriptor array.
|
| { MaybeObject* maybe_array =
|
| - Heap::AllocateFixedArray(number_of_descriptors << 1);
|
| + heap->AllocateFixedArray(number_of_descriptors << 1);
|
| if (!maybe_array->ToObject(&array)) return maybe_array;
|
| }
|
| result->set(kContentArrayIndex, array);
|
| @@ -4235,15 +4323,15 @@
|
| MaybeObject* DeoptimizationInputData::Allocate(int deopt_entry_count,
|
| PretenureFlag pretenure) {
|
| ASSERT(deopt_entry_count > 0);
|
| - return Heap::AllocateFixedArray(LengthFor(deopt_entry_count),
|
| + return HEAP->AllocateFixedArray(LengthFor(deopt_entry_count),
|
| pretenure);
|
| }
|
|
|
|
|
| MaybeObject* DeoptimizationOutputData::Allocate(int number_of_deopt_points,
|
| PretenureFlag pretenure) {
|
| - if (number_of_deopt_points == 0) return Heap::empty_fixed_array();
|
| - return Heap::AllocateFixedArray(LengthOfFixedArray(number_of_deopt_points),
|
| + if (number_of_deopt_points == 0) return HEAP->empty_fixed_array();
|
| + return HEAP->AllocateFixedArray(LengthOfFixedArray(number_of_deopt_points),
|
| pretenure);
|
| }
|
|
|
| @@ -4261,11 +4349,8 @@
|
| #endif
|
|
|
|
|
| -static StaticResource<StringInputBuffer> string_input_buffer;
|
| -
|
| -
|
| bool String::LooksValid() {
|
| - if (!Heap::Contains(this)) return false;
|
| + if (!Isolate::Current()->heap()->Contains(this)) return false;
|
| return true;
|
| }
|
|
|
| @@ -4276,8 +4361,10 @@
|
| // doesn't make Utf8Length faster, but it is very likely that
|
| // the string will be accessed later (for example by WriteUtf8)
|
| // so it's still a good idea.
|
| + Heap* heap = GetHeap();
|
| TryFlatten();
|
| - Access<StringInputBuffer> buffer(&string_input_buffer);
|
| + Access<StringInputBuffer> buffer(
|
| + heap->isolate()->objects_string_input_buffer());
|
| buffer->Reset(0, this);
|
| int result = 0;
|
| while (buffer->has_more())
|
| @@ -4347,12 +4434,14 @@
|
| if (robust_flag == ROBUST_STRING_TRAVERSAL && !LooksValid()) {
|
| return SmartPointer<char>(NULL);
|
| }
|
| + Heap* heap = GetHeap();
|
|
|
| // Negative length means the to the end of the string.
|
| if (length < 0) length = kMaxInt - offset;
|
|
|
| // Compute the size of the UTF-8 string. Start at the specified offset.
|
| - Access<StringInputBuffer> buffer(&string_input_buffer);
|
| + Access<StringInputBuffer> buffer(
|
| + heap->isolate()->objects_string_input_buffer());
|
| buffer->Reset(offset, this);
|
| int character_position = offset;
|
| int utf8_bytes = 0;
|
| @@ -4422,12 +4511,13 @@
|
|
|
| SmartPointer<uc16> String::ToWideCString(RobustnessFlag robust_flag) {
|
| ASSERT(NativeAllocationChecker::allocation_allowed());
|
| -
|
| if (robust_flag == ROBUST_STRING_TRAVERSAL && !LooksValid()) {
|
| return SmartPointer<uc16>();
|
| }
|
| + Heap* heap = GetHeap();
|
|
|
| - Access<StringInputBuffer> buffer(&string_input_buffer);
|
| + Access<StringInputBuffer> buffer(
|
| + heap->isolate()->objects_string_input_buffer());
|
| buffer->Reset(this);
|
|
|
| uc16* result = NewArray<uc16>(length() + 1);
|
| @@ -4710,11 +4800,9 @@
|
| }
|
|
|
|
|
| -Relocatable* Relocatable::top_ = NULL;
|
| -
|
| -
|
| void Relocatable::PostGarbageCollectionProcessing() {
|
| - Relocatable* current = top_;
|
| + Isolate* isolate = Isolate::Current();
|
| + Relocatable* current = isolate->relocatable_top();
|
| while (current != NULL) {
|
| current->PostGarbageCollection();
|
| current = current->prev_;
|
| @@ -4724,21 +4812,23 @@
|
|
|
| // Reserve space for statics needing saving and restoring.
|
| int Relocatable::ArchiveSpacePerThread() {
|
| - return sizeof(top_);
|
| + return sizeof(Isolate::Current()->relocatable_top());
|
| }
|
|
|
|
|
| // Archive statics that are thread local.
|
| char* Relocatable::ArchiveState(char* to) {
|
| - *reinterpret_cast<Relocatable**>(to) = top_;
|
| - top_ = NULL;
|
| + Isolate* isolate = Isolate::Current();
|
| + *reinterpret_cast<Relocatable**>(to) = isolate->relocatable_top();
|
| + isolate->set_relocatable_top(NULL);
|
| return to + ArchiveSpacePerThread();
|
| }
|
|
|
|
|
| // Restore statics that are thread local.
|
| char* Relocatable::RestoreState(char* from) {
|
| - top_ = *reinterpret_cast<Relocatable**>(from);
|
| + Isolate* isolate = Isolate::Current();
|
| + isolate->set_relocatable_top(*reinterpret_cast<Relocatable**>(from));
|
| return from + ArchiveSpacePerThread();
|
| }
|
|
|
| @@ -4751,7 +4841,8 @@
|
|
|
|
|
| void Relocatable::Iterate(ObjectVisitor* v) {
|
| - Iterate(v, top_);
|
| + Isolate* isolate = Isolate::Current();
|
| + Iterate(v, isolate->relocatable_top());
|
| }
|
|
|
|
|
| @@ -4764,15 +4855,17 @@
|
| }
|
|
|
|
|
| -FlatStringReader::FlatStringReader(Handle<String> str)
|
| - : str_(str.location()),
|
| +FlatStringReader::FlatStringReader(Isolate* isolate, Handle<String> str)
|
| + : Relocatable(isolate),
|
| + str_(str.location()),
|
| length_(str->length()) {
|
| PostGarbageCollection();
|
| }
|
|
|
|
|
| -FlatStringReader::FlatStringReader(Vector<const char> input)
|
| - : str_(0),
|
| +FlatStringReader::FlatStringReader(Isolate* isolate, Vector<const char> input)
|
| + : Relocatable(isolate),
|
| + str_(0),
|
| is_ascii_(true),
|
| length_(input.length()),
|
| start_(input.start()) { }
|
| @@ -5102,11 +5195,10 @@
|
| }
|
|
|
|
|
| -static StringInputBuffer string_compare_buffer_b;
|
| -
|
| -
|
| template <typename IteratorA>
|
| -static inline bool CompareStringContentsPartial(IteratorA* ia, String* b) {
|
| +static inline bool CompareStringContentsPartial(Isolate* isolate,
|
| + IteratorA* ia,
|
| + String* b) {
|
| if (b->IsFlat()) {
|
| if (b->IsAsciiRepresentation()) {
|
| VectorIterator<char> ib(b->ToAsciiVector());
|
| @@ -5116,16 +5208,16 @@
|
| return CompareStringContents(ia, &ib);
|
| }
|
| } else {
|
| - string_compare_buffer_b.Reset(0, b);
|
| - return CompareStringContents(ia, &string_compare_buffer_b);
|
| + isolate->objects_string_compare_buffer_b()->Reset(0, b);
|
| + return CompareStringContents(ia,
|
| + isolate->objects_string_compare_buffer_b());
|
| }
|
| }
|
|
|
|
|
| -static StringInputBuffer string_compare_buffer_a;
|
| +bool String::SlowEquals(String* other) {
|
| + Heap* heap = GetHeap();
|
|
|
| -
|
| -bool String::SlowEquals(String* other) {
|
| // Fast check: negative check with lengths.
|
| int len = length();
|
| if (len != other->length()) return false;
|
| @@ -5152,6 +5244,7 @@
|
| Vector<const char>(str2, len));
|
| }
|
|
|
| + Isolate* isolate = heap->isolate();
|
| if (lhs->IsFlat()) {
|
| if (lhs->IsAsciiRepresentation()) {
|
| Vector<const char> vec1 = lhs->ToAsciiVector();
|
| @@ -5166,8 +5259,9 @@
|
| }
|
| } else {
|
| VectorIterator<char> buf1(vec1);
|
| - string_compare_buffer_b.Reset(0, rhs);
|
| - return CompareStringContents(&buf1, &string_compare_buffer_b);
|
| + isolate->objects_string_compare_buffer_b()->Reset(0, rhs);
|
| + return CompareStringContents(&buf1,
|
| + isolate->objects_string_compare_buffer_b());
|
| }
|
| } else {
|
| Vector<const uc16> vec1 = lhs->ToUC16Vector();
|
| @@ -5182,13 +5276,15 @@
|
| }
|
| } else {
|
| VectorIterator<uc16> buf1(vec1);
|
| - string_compare_buffer_b.Reset(0, rhs);
|
| - return CompareStringContents(&buf1, &string_compare_buffer_b);
|
| + isolate->objects_string_compare_buffer_b()->Reset(0, rhs);
|
| + return CompareStringContents(&buf1,
|
| + isolate->objects_string_compare_buffer_b());
|
| }
|
| }
|
| } else {
|
| - string_compare_buffer_a.Reset(0, lhs);
|
| - return CompareStringContentsPartial(&string_compare_buffer_a, rhs);
|
| + isolate->objects_string_compare_buffer_a()->Reset(0, lhs);
|
| + return CompareStringContentsPartial(isolate,
|
| + isolate->objects_string_compare_buffer_a(), rhs);
|
| }
|
| }
|
|
|
| @@ -5197,11 +5293,12 @@
|
| if (StringShape(this).IsSymbol()) return false;
|
|
|
| Map* map = this->map();
|
| - if (map == Heap::string_map()) {
|
| - this->set_map(Heap::undetectable_string_map());
|
| + Heap* heap = map->GetHeap();
|
| + if (map == heap->string_map()) {
|
| + this->set_map(heap->undetectable_string_map());
|
| return true;
|
| - } else if (map == Heap::ascii_string_map()) {
|
| - this->set_map(Heap::undetectable_ascii_string_map());
|
| + } else if (map == heap->ascii_string_map()) {
|
| + this->set_map(heap->undetectable_ascii_string_map());
|
| return true;
|
| }
|
| // Rest cannot be marked as undetectable
|
| @@ -5210,9 +5307,10 @@
|
|
|
|
|
| bool String::IsEqualTo(Vector<const char> str) {
|
| + Isolate* isolate = GetIsolate();
|
| int slen = length();
|
| Access<ScannerConstants::Utf8Decoder>
|
| - decoder(ScannerConstants::utf8_decoder());
|
| + decoder(isolate->scanner_constants()->utf8_decoder());
|
| decoder->Reset(str.start(), str.length());
|
| int i;
|
| for (i = 0; i < slen && decoder->has_more(); i++) {
|
| @@ -5374,8 +5472,9 @@
|
|
|
|
|
| MaybeObject* String::SubString(int start, int end, PretenureFlag pretenure) {
|
| + Heap* heap = GetHeap();
|
| if (start == 0 && end == length()) return this;
|
| - MaybeObject* result = Heap::AllocateSubString(this, start, end, pretenure);
|
| + MaybeObject* result = heap->AllocateSubString(this, start, end, pretenure);
|
| return result;
|
| }
|
|
|
| @@ -5415,12 +5514,12 @@
|
| }
|
|
|
|
|
| -void Map::ClearNonLiveTransitions(Object* real_prototype) {
|
| +void Map::ClearNonLiveTransitions(Heap* heap, Object* real_prototype) {
|
| // Live DescriptorArray objects will be marked, so we must use
|
| // low-level accessors to get and modify their data.
|
| DescriptorArray* d = reinterpret_cast<DescriptorArray*>(
|
| *RawField(this, Map::kInstanceDescriptorsOffset));
|
| - if (d == Heap::raw_unchecked_empty_descriptor_array()) return;
|
| + if (d == heap->raw_unchecked_empty_descriptor_array()) return;
|
| Smi* NullDescriptorDetails =
|
| PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi();
|
| FixedArray* contents = reinterpret_cast<FixedArray*>(
|
| @@ -5437,11 +5536,11 @@
|
| details.type() == CONSTANT_TRANSITION) {
|
| Map* target = reinterpret_cast<Map*>(contents->get(i));
|
| ASSERT(target->IsHeapObject());
|
| - MarkBit map_mark = Marking::MarkBitFrom(target);
|
| + MarkBit map_mark = heap->marking()->MarkBitFrom(target);
|
| if (!map_mark.Get()) {
|
| ASSERT(target->IsMap());
|
| contents->set_unchecked(i + 1, NullDescriptorDetails);
|
| - contents->set_null_unchecked(i);
|
| + contents->set_null_unchecked(heap, i);
|
| ASSERT(target->prototype() == this ||
|
| target->prototype() == real_prototype);
|
| // Getter prototype() is read-only, set_prototype() has side effects.
|
| @@ -5465,7 +5564,8 @@
|
| ASSERT(is_compiled() && !IsOptimized());
|
| ASSERT(shared()->allows_lazy_compilation() ||
|
| code()->optimizable());
|
| - ReplaceCode(Builtins::builtin(Builtins::LazyRecompile));
|
| + Builtins* builtins = GetIsolate()->builtins();
|
| + ReplaceCode(builtins->builtin(Builtins::LazyRecompile));
|
| }
|
|
|
|
|
| @@ -5498,7 +5598,7 @@
|
|
|
| Object* JSFunction::SetInstancePrototype(Object* value) {
|
| ASSERT(value->IsJSObject());
|
| -
|
| + Heap* heap = GetHeap();
|
| if (has_initial_map()) {
|
| initial_map()->set_prototype(value);
|
| } else {
|
| @@ -5507,7 +5607,7 @@
|
| // prototype is put into the initial map where it belongs.
|
| set_prototype_or_initial_map(value);
|
| }
|
| - Heap::ClearInstanceofCache();
|
| + heap->ClearInstanceofCache();
|
| return value;
|
| }
|
|
|
| @@ -5521,6 +5621,7 @@
|
| // used for constructing objects to the original object prototype.
|
| // See ECMA-262 13.2.2.
|
| if (!value->IsJSObject()) {
|
| + Heap* heap = GetHeap();
|
| // Copy the map so this does not affect unrelated functions.
|
| // Remove map transitions because they point to maps with a
|
| // different prototype.
|
| @@ -5532,7 +5633,8 @@
|
| map()->set_constructor(value);
|
| map()->set_non_instance_prototype(true);
|
| construct_prototype =
|
| - Top::context()->global_context()->initial_object_prototype();
|
| + heap->isolate()->context()->global_context()->
|
| + initial_object_prototype();
|
| } else {
|
| map()->set_non_instance_prototype(false);
|
| }
|
| @@ -5557,7 +5659,7 @@
|
| ASSERT(shared()->strict_mode() || map() == global_context->function_map());
|
|
|
| set_map(no_prototype_map);
|
| - set_prototype_or_initial_map(Heap::the_hole_value());
|
| + set_prototype_or_initial_map(GetHeap()->the_hole_value());
|
| return this;
|
| }
|
|
|
| @@ -5579,13 +5681,17 @@
|
| }
|
|
|
|
|
| -MaybeObject* Oddball::Initialize(const char* to_string, Object* to_number) {
|
| +MaybeObject* Oddball::Initialize(const char* to_string,
|
| + Object* to_number,
|
| + byte kind) {
|
| Object* symbol;
|
| - { MaybeObject* maybe_symbol = Heap::LookupAsciiSymbol(to_string);
|
| + { MaybeObject* maybe_symbol =
|
| + Isolate::Current()->heap()->LookupAsciiSymbol(to_string);
|
| if (!maybe_symbol->ToObject(&symbol)) return maybe_symbol;
|
| }
|
| set_to_string(String::cast(symbol));
|
| set_to_number(to_number);
|
| + set_kind(kind);
|
| return this;
|
| }
|
|
|
| @@ -5604,10 +5710,11 @@
|
|
|
|
|
| Object* SharedFunctionInfo::GetSourceCode() {
|
| - if (!HasSourceCode()) return Heap::undefined_value();
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + if (!HasSourceCode()) return isolate->heap()->undefined_value();
|
| + HandleScope scope(isolate);
|
| Object* source = Script::cast(script())->source();
|
| - return *SubString(Handle<String>(String::cast(source)),
|
| + return *SubString(Handle<String>(String::cast(source), isolate),
|
| start_position(), end_position());
|
| }
|
|
|
| @@ -5634,6 +5741,8 @@
|
|
|
|
|
| bool SharedFunctionInfo::CanGenerateInlineConstructor(Object* prototype) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Check the basic conditions for generating inline constructor code.
|
| if (!FLAG_inline_new
|
| || !has_only_simple_this_property_assignments()
|
| @@ -5650,7 +5759,7 @@
|
| // Traverse the proposed prototype chain looking for setters for properties of
|
| // the same names as are set by the inline constructor.
|
| for (Object* obj = prototype;
|
| - obj != Heap::null_value();
|
| + obj != heap->null_value();
|
| obj = obj->GetPrototype()) {
|
| JSObject* js_object = JSObject::cast(obj);
|
| for (int i = 0; i < this_property_assignments_count(); i++) {
|
| @@ -5686,10 +5795,11 @@
|
|
|
|
|
| void SharedFunctionInfo::ClearThisPropertyAssignmentsInfo() {
|
| + Heap* heap = GetHeap();
|
| set_compiler_hints(BooleanBit::set(compiler_hints(),
|
| kHasOnlySimpleThisPropertyAssignments,
|
| false));
|
| - set_this_property_assignments(Heap::undefined_value());
|
| + set_this_property_assignments(heap->undefined_value());
|
| set_this_property_assignments_count(0);
|
| }
|
|
|
| @@ -5834,9 +5944,10 @@
|
| set_construction_count(kGenerousAllocationCount);
|
| }
|
| set_initial_map(map);
|
| - ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubGeneric),
|
| + Builtins* builtins = map->heap()->isolate()->builtins();
|
| + ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric),
|
| construct_stub());
|
| - set_construct_stub(Builtins::builtin(Builtins::JSConstructStubCountdown));
|
| + set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown));
|
| }
|
|
|
|
|
| @@ -5853,10 +5964,11 @@
|
| // then StartInobjectTracking will be called again the next time the
|
| // constructor is called. The countdown will continue and (possibly after
|
| // several more GCs) CompleteInobjectSlackTracking will eventually be called.
|
| - set_initial_map(Heap::raw_unchecked_undefined_value());
|
| - ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubCountdown),
|
| + set_initial_map(map->heap()->raw_unchecked_undefined_value());
|
| + Builtins* builtins = map->heap()->isolate()->builtins();
|
| + ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown),
|
| *RawField(this, kConstructStubOffset));
|
| - set_construct_stub(Builtins::builtin(Builtins::JSConstructStubGeneric));
|
| + set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric));
|
| // It is safe to clear the flag: it will be set again if the map is live.
|
| set_live_objects_may_exist(false);
|
| }
|
| @@ -5869,9 +5981,10 @@
|
|
|
| // Resume inobject slack tracking.
|
| set_initial_map(map);
|
| - ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubGeneric),
|
| + Builtins* builtins = map->heap()->isolate()->builtins();
|
| + ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric),
|
| *RawField(this, kConstructStubOffset));
|
| - set_construct_stub(Builtins::builtin(Builtins::JSConstructStubCountdown));
|
| + set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown));
|
| // The map survived the gc, so there may be objects referencing it.
|
| set_live_objects_may_exist(true);
|
| }
|
| @@ -5900,10 +6013,12 @@
|
| ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress());
|
| Map* map = Map::cast(initial_map());
|
|
|
| - set_initial_map(Heap::undefined_value());
|
| - ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubCountdown),
|
| + Heap* heap = map->heap();
|
| + set_initial_map(heap->undefined_value());
|
| + Builtins* builtins = heap->isolate()->builtins();
|
| + ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown),
|
| construct_stub());
|
| - set_construct_stub(Builtins::builtin(Builtins::JSConstructStubGeneric));
|
| + set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric));
|
|
|
| int slack = map->unused_property_fields();
|
| map->TraverseTransitionTree(&GetMinInobjectSlack, &slack);
|
| @@ -5960,8 +6075,7 @@
|
|
|
|
|
| void Code::InvalidateRelocation() {
|
| - HandleScope scope;
|
| - set_relocation_info(Heap::empty_byte_array());
|
| + set_relocation_info(GetHeap()->empty_byte_array());
|
| }
|
|
|
|
|
| @@ -6407,11 +6521,12 @@
|
|
|
| MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity,
|
| int length) {
|
| + Heap* heap = GetHeap();
|
| // We should never end in here with a pixel or external array.
|
| ASSERT(!HasExternalArrayElements());
|
|
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(capacity);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* elems = FixedArray::cast(obj);
|
| @@ -6498,14 +6613,15 @@
|
|
|
|
|
| MaybeObject* JSArray::Initialize(int capacity) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(capacity >= 0);
|
| set_length(Smi::FromInt(0));
|
| FixedArray* new_elements;
|
| if (capacity == 0) {
|
| - new_elements = Heap::empty_fixed_array();
|
| + new_elements = heap->empty_fixed_array();
|
| } else {
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(capacity);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| new_elements = FixedArray::cast(obj);
|
| @@ -6520,21 +6636,23 @@
|
| Handle<FixedArray> old_backing(FixedArray::cast(elements()));
|
| int old_size = old_backing->length();
|
| int new_size = required_size > old_size ? required_size : old_size;
|
| - Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size);
|
| + Handle<FixedArray> new_backing = FACTORY->NewFixedArray(new_size);
|
| // Can't use this any more now because we may have had a GC!
|
| for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i));
|
| self->SetContent(*new_backing);
|
| }
|
|
|
|
|
| -static Failure* ArrayLengthRangeError() {
|
| +static Failure* ArrayLengthRangeError(Heap* heap) {
|
| HandleScope scope;
|
| - return Top::Throw(*Factory::NewRangeError("invalid_array_length",
|
| - HandleVector<Object>(NULL, 0)));
|
| + return heap->isolate()->Throw(
|
| + *FACTORY->NewRangeError("invalid_array_length",
|
| + HandleVector<Object>(NULL, 0)));
|
| }
|
|
|
|
|
| MaybeObject* JSObject::SetElementsLength(Object* len) {
|
| + Heap* heap = GetHeap();
|
| // We should never end in here with a pixel or external array.
|
| ASSERT(AllowsSetElementsLength());
|
|
|
| @@ -6542,7 +6660,7 @@
|
| Object* smi_length = Smi::FromInt(0);
|
| if (maybe_smi_length->ToObject(&smi_length) && smi_length->IsSmi()) {
|
| const int value = Smi::cast(smi_length)->value();
|
| - if (value < 0) return ArrayLengthRangeError();
|
| + if (value < 0) return ArrayLengthRangeError(heap);
|
| switch (GetElementsKind()) {
|
| case FAST_ELEMENTS: {
|
| int old_capacity = FixedArray::cast(elements())->length();
|
| @@ -6608,14 +6726,14 @@
|
| if (len->ToArrayIndex(&length)) {
|
| return SetSlowElements(len);
|
| } else {
|
| - return ArrayLengthRangeError();
|
| + return ArrayLengthRangeError(heap);
|
| }
|
| }
|
|
|
| // len is not a number so make the array size one and
|
| // set only element to len.
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(1);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(1);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray::cast(obj)->set(0, len);
|
| @@ -6627,6 +6745,7 @@
|
|
|
| MaybeObject* JSObject::SetPrototype(Object* value,
|
| bool skip_hidden_prototypes) {
|
| + Heap* heap = GetHeap();
|
| // Silently ignore the change if value is not a JSObject or null.
|
| // SpiderMonkey behaves this way.
|
| if (!value->IsJSObject() && !value->IsNull()) return value;
|
| @@ -6635,12 +6754,12 @@
|
| // prototype cycles are prevented.
|
| // It is sufficient to validate that the receiver is not in the new prototype
|
| // chain.
|
| - for (Object* pt = value; pt != Heap::null_value(); pt = pt->GetPrototype()) {
|
| + for (Object* pt = value; pt != heap->null_value(); pt = pt->GetPrototype()) {
|
| if (JSObject::cast(pt) == this) {
|
| // Cycle detected.
|
| HandleScope scope;
|
| - return Top::Throw(*Factory::NewError("cyclic_proto",
|
| - HandleVector<Object>(NULL, 0)));
|
| + return heap->isolate()->Throw(
|
| + *FACTORY->NewError("cyclic_proto", HandleVector<Object>(NULL, 0)));
|
| }
|
| }
|
|
|
| @@ -6665,7 +6784,7 @@
|
| Map::cast(new_map)->set_prototype(value);
|
| real_receiver->set_map(Map::cast(new_map));
|
|
|
| - Heap::ClearInstanceofCache();
|
| + heap->ClearInstanceofCache();
|
|
|
| return value;
|
| }
|
| @@ -6720,29 +6839,31 @@
|
| if (this->IsStringObjectWithCharacterAt(index)) return true;
|
|
|
| Object* pt = GetPrototype();
|
| - if (pt == Heap::null_value()) return false;
|
| + if (pt->IsNull()) return false;
|
| return JSObject::cast(pt)->HasElementWithReceiver(receiver, index);
|
| }
|
|
|
|
|
| bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) {
|
| + Isolate* isolate = GetIsolate();
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
|
| Handle<JSObject> receiver_handle(receiver);
|
| Handle<JSObject> holder_handle(this);
|
| - CustomArguments args(interceptor->data(), receiver, this);
|
| + CustomArguments args(isolate, interceptor->data(), receiver, this);
|
| v8::AccessorInfo info(args.end());
|
| if (!interceptor->query()->IsUndefined()) {
|
| v8::IndexedPropertyQuery query =
|
| v8::ToCData<v8::IndexedPropertyQuery>(interceptor->query());
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-has", this, index));
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-has", this, index));
|
| v8::Handle<v8::Integer> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = query(index, info);
|
| }
|
| if (!result.IsEmpty()) {
|
| @@ -6752,11 +6873,12 @@
|
| } else if (!interceptor->getter()->IsUndefined()) {
|
| v8::IndexedPropertyGetter getter =
|
| v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter());
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-has-get", this, index));
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-has-get", this, index));
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = getter(index, info);
|
| }
|
| if (!result.IsEmpty()) return true;
|
| @@ -6766,10 +6888,12 @@
|
|
|
|
|
| JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return UNDEFINED_ELEMENT;
|
| }
|
|
|
| @@ -6836,10 +6960,12 @@
|
|
|
|
|
| bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return false;
|
| }
|
|
|
| @@ -6894,7 +7020,7 @@
|
| if (this->IsStringObjectWithCharacterAt(index)) return true;
|
|
|
| Object* pt = GetPrototype();
|
| - if (pt == Heap::null_value()) return false;
|
| + if (pt->IsNull()) return false;
|
| return JSObject::cast(pt)->HasElementWithReceiver(receiver, index);
|
| }
|
|
|
| @@ -6903,26 +7029,28 @@
|
| Object* value,
|
| StrictModeFlag strict_mode,
|
| bool check_prototype) {
|
| + Isolate* isolate = GetIsolate();
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
|
| Handle<JSObject> this_handle(this);
|
| - Handle<Object> value_handle(value);
|
| + Handle<Object> value_handle(value, isolate);
|
| if (!interceptor->setter()->IsUndefined()) {
|
| v8::IndexedPropertySetter setter =
|
| v8::ToCData<v8::IndexedPropertySetter>(interceptor->setter());
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-set", this, index));
|
| - CustomArguments args(interceptor->data(), this, this);
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-set", this, index));
|
| + CustomArguments args(isolate, interceptor->data(), this, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = setter(index, v8::Utils::ToLocal(value_handle), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) return *value_handle;
|
| }
|
| MaybeObject* raw_result =
|
| @@ -6930,7 +7058,7 @@
|
| *value_handle,
|
| strict_mode,
|
| check_prototype);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
| @@ -6939,6 +7067,7 @@
|
| Object* structure,
|
| uint32_t index,
|
| Object* holder) {
|
| + Isolate* isolate = GetIsolate();
|
| ASSERT(!structure->IsProxy());
|
|
|
| // api style callbacks.
|
| @@ -6946,22 +7075,22 @@
|
| AccessorInfo* data = AccessorInfo::cast(structure);
|
| Object* fun_obj = data->getter();
|
| v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<JSObject> self(JSObject::cast(receiver));
|
| Handle<JSObject> holder_handle(JSObject::cast(holder));
|
| - Handle<Object> number = Factory::NewNumberFromUint(index);
|
| - Handle<String> key(Factory::NumberToString(number));
|
| - LOG(ApiNamedPropertyAccess("load", *self, *key));
|
| - CustomArguments args(data->data(), *self, *holder_handle);
|
| + Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
|
| + Handle<String> key(isolate->factory()->NumberToString(number));
|
| + LOG(isolate, ApiNamedPropertyAccess("load", *self, *key));
|
| + CustomArguments args(isolate, data->data(), *self, *holder_handle);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = call_fun(v8::Utils::ToLocal(key), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| - if (result.IsEmpty()) return Heap::undefined_value();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| + if (result.IsEmpty()) return isolate->heap()->undefined_value();
|
| return *v8::Utils::OpenHandle(*result);
|
| }
|
|
|
| @@ -6973,7 +7102,7 @@
|
| JSFunction::cast(getter));
|
| }
|
| // Getter is not a function.
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| UNREACHABLE();
|
| @@ -6985,12 +7114,13 @@
|
| uint32_t index,
|
| Object* value,
|
| JSObject* holder) {
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + HandleScope scope(isolate);
|
|
|
| // We should never get here to initialize a const with the hole
|
| // value since a const declaration would conflict with the setter.
|
| ASSERT(!value->IsTheHole());
|
| - Handle<Object> value_handle(value);
|
| + Handle<Object> value_handle(value, isolate);
|
|
|
| // To accommodate both the old and the new api we switch on the
|
| // data structure used to store the callbacks. Eventually proxy
|
| @@ -7003,19 +7133,19 @@
|
| Object* call_obj = data->setter();
|
| v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj);
|
| if (call_fun == NULL) return value;
|
| - Handle<Object> number = Factory::NewNumberFromUint(index);
|
| - Handle<String> key(Factory::NumberToString(number));
|
| - LOG(ApiNamedPropertyAccess("store", this, *key));
|
| - CustomArguments args(data->data(), this, JSObject::cast(holder));
|
| + Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
|
| + Handle<String> key(isolate->factory()->NumberToString(number));
|
| + LOG(isolate, ApiNamedPropertyAccess("store", this, *key));
|
| + CustomArguments args(isolate, data->data(), this, JSObject::cast(holder));
|
| v8::AccessorInfo info(args.end());
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| call_fun(v8::Utils::ToLocal(key),
|
| v8::Utils::ToLocal(value_handle),
|
| info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return *value_handle;
|
| }
|
|
|
| @@ -7024,11 +7154,12 @@
|
| if (setter->IsJSFunction()) {
|
| return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value);
|
| } else {
|
| - Handle<Object> holder_handle(holder);
|
| - Handle<Object> key(Factory::NewNumberFromUint(index));
|
| + Handle<Object> holder_handle(holder, isolate);
|
| + Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
|
| Handle<Object> args[2] = { key, holder_handle };
|
| - return Top::Throw(*Factory::NewTypeError("no_setter_in_callback",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(
|
| + *isolate->factory()->NewTypeError("no_setter_in_callback",
|
| + HandleVector(args, 2)));
|
| }
|
| }
|
|
|
| @@ -7107,12 +7238,13 @@
|
| Object* value,
|
| StrictModeFlag strict_mode,
|
| bool check_prototype) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_SET)) {
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) {
|
| HandleScope scope;
|
| Handle<Object> value_handle(value);
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| return *value_handle;
|
| }
|
|
|
| @@ -7145,6 +7277,7 @@
|
| Object* value,
|
| StrictModeFlag strict_mode,
|
| bool check_prototype) {
|
| + Isolate* isolate = GetIsolate();
|
| switch (GetElementsKind()) {
|
| case FAST_ELEMENTS:
|
| // Fast case.
|
| @@ -7200,12 +7333,12 @@
|
| // If put fails instrict mode, throw exception.
|
| if (!dictionary->ValueAtPut(entry, value) &&
|
| strict_mode == kStrictMode) {
|
| - Handle<Object> number(Factory::NewNumberFromUint(index));
|
| + Handle<Object> number(isolate->factory()->NewNumberFromUint(index));
|
| Handle<Object> holder(this);
|
| Handle<Object> args[2] = { number, holder };
|
| - return Top::Throw(
|
| - *Factory::NewTypeError("strict_read_only_property",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(
|
| + *isolate->factory()->NewTypeError("strict_read_only_property",
|
| + HandleVector(args, 2)));
|
| }
|
| }
|
| } else {
|
| @@ -7220,11 +7353,13 @@
|
| // When we set the is_extensible flag to false we always force
|
| // the element into dictionary mode (and force them to stay there).
|
| if (!map()->is_extensible()) {
|
| - Handle<Object> number(Factory::NewNumberFromUint(index));
|
| - Handle<String> index_string(Factory::NumberToString(number));
|
| + Handle<Object> number(isolate->factory()->NewNumberFromUint(index));
|
| + Handle<String> index_string(
|
| + isolate->factory()->NumberToString(number));
|
| Handle<Object> args[1] = { index_string };
|
| - return Top::Throw(*Factory::NewTypeError("object_not_extensible",
|
| - HandleVector(args, 1)));
|
| + return isolate->Throw(
|
| + *isolate->factory()->NewTypeError("object_not_extensible",
|
| + HandleVector(args, 1)));
|
| }
|
| Object* result;
|
| { MaybeObject* maybe_result = dictionary->AtNumberPut(index, value);
|
| @@ -7277,7 +7412,7 @@
|
| // All possible cases have been handled above. Add a return to avoid the
|
| // complaints from the compiler.
|
| UNREACHABLE();
|
| - return Heap::null_value();
|
| + return isolate->heap()->null_value();
|
| }
|
|
|
|
|
| @@ -7290,7 +7425,7 @@
|
| if (index >= old_len && index != 0xffffffff) {
|
| Object* len;
|
| { MaybeObject* maybe_len =
|
| - Heap::NumberFromDouble(static_cast<double>(index) + 1);
|
| + GetHeap()->NumberFromDouble(static_cast<double>(index) + 1);
|
| if (!maybe_len->ToObject(&len)) return maybe_len;
|
| }
|
| set_length(len);
|
| @@ -7301,6 +7436,7 @@
|
|
|
| MaybeObject* JSObject::GetElementPostInterceptor(Object* receiver,
|
| uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| // Get element works for both JSObject and JSArray since
|
| // JSArray::length cannot change.
|
| switch (GetElementsKind()) {
|
| @@ -7349,17 +7485,18 @@
|
|
|
| // Continue searching via the prototype chain.
|
| Object* pt = GetPrototype();
|
| - if (pt == Heap::null_value()) return Heap::undefined_value();
|
| + if (pt->IsNull()) return heap->undefined_value();
|
| return pt->GetElementWithReceiver(receiver, index);
|
| }
|
|
|
|
|
| MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver,
|
| uint32_t index) {
|
| + Isolate* isolate = GetIsolate();
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
|
| Handle<Object> this_handle(receiver);
|
| Handle<JSObject> holder_handle(this);
|
| @@ -7367,33 +7504,35 @@
|
| if (!interceptor->getter()->IsUndefined()) {
|
| v8::IndexedPropertyGetter getter =
|
| v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter());
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-get", this, index));
|
| - CustomArguments args(interceptor->data(), receiver, this);
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-get", this, index));
|
| + CustomArguments args(isolate, interceptor->data(), receiver, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = getter(index, info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
|
| }
|
|
|
| MaybeObject* raw_result =
|
| holder_handle->GetElementPostInterceptor(*this_handle, index);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
|
|
| MaybeObject* JSObject::GetElementWithReceiver(Object* receiver,
|
| uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_GET)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_GET);
|
| - return Heap::undefined_value();
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_GET)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
|
| + return heap->undefined_value();
|
| }
|
|
|
| if (HasIndexedInterceptor()) {
|
| @@ -7444,7 +7583,7 @@
|
| }
|
|
|
| Object* pt = GetPrototype();
|
| - if (pt == Heap::null_value()) return Heap::undefined_value();
|
| + if (pt == heap->null_value()) return heap->undefined_value();
|
| return pt->GetElementWithReceiver(receiver, index);
|
| }
|
|
|
| @@ -7499,7 +7638,7 @@
|
| ExternalIntArray* array = ExternalIntArray::cast(elements());
|
| if (index < static_cast<uint32_t>(array->length())) {
|
| int32_t value = array->get(index);
|
| - return Heap::NumberFromInt32(value);
|
| + return GetHeap()->NumberFromInt32(value);
|
| }
|
| break;
|
| }
|
| @@ -7508,7 +7647,7 @@
|
| ExternalUnsignedIntArray::cast(elements());
|
| if (index < static_cast<uint32_t>(array->length())) {
|
| uint32_t value = array->get(index);
|
| - return Heap::NumberFromUint32(value);
|
| + return GetHeap()->NumberFromUint32(value);
|
| }
|
| break;
|
| }
|
| @@ -7516,7 +7655,7 @@
|
| ExternalFloatArray* array = ExternalFloatArray::cast(elements());
|
| if (index < static_cast<uint32_t>(array->length())) {
|
| float value = array->get(index);
|
| - return Heap::AllocateHeapNumber(value);
|
| + return GetHeap()->AllocateHeapNumber(value);
|
| }
|
| break;
|
| }
|
| @@ -7525,7 +7664,7 @@
|
| UNREACHABLE();
|
| break;
|
| }
|
| - return Heap::undefined_value();
|
| + return GetHeap()->undefined_value();
|
| }
|
|
|
|
|
| @@ -7670,6 +7809,7 @@
|
| JSObject* receiver,
|
| String* name,
|
| PropertyAttributes* attributes) {
|
| + Heap* heap = GetHeap();
|
| // Check local property in holder, ignore interceptor.
|
| LookupResult result;
|
| LocalLookupRealNamedProperty(name, &result);
|
| @@ -7679,7 +7819,7 @@
|
| // Continue searching via the prototype chain.
|
| Object* pt = GetPrototype();
|
| *attributes = ABSENT;
|
| - if (pt == Heap::null_value()) return Heap::undefined_value();
|
| + if (pt->IsNull()) return heap->undefined_value();
|
| return pt->GetPropertyWithReceiver(receiver, name, attributes);
|
| }
|
|
|
| @@ -7688,13 +7828,14 @@
|
| JSObject* receiver,
|
| String* name,
|
| PropertyAttributes* attributes) {
|
| + Heap* heap = GetHeap();
|
| // Check local property in holder, ignore interceptor.
|
| LookupResult result;
|
| LocalLookupRealNamedProperty(name, &result);
|
| if (result.IsProperty()) {
|
| return GetProperty(receiver, &result, name, attributes);
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| @@ -7702,8 +7843,9 @@
|
| JSObject* receiver,
|
| String* name,
|
| PropertyAttributes* attributes) {
|
| + Isolate* isolate = GetIsolate();
|
| InterceptorInfo* interceptor = GetNamedInterceptor();
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<JSObject> receiver_handle(receiver);
|
| Handle<JSObject> holder_handle(this);
|
| Handle<String> name_handle(name);
|
| @@ -7711,16 +7853,17 @@
|
| if (!interceptor->getter()->IsUndefined()) {
|
| v8::NamedPropertyGetter getter =
|
| v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name));
|
| - CustomArguments args(interceptor->data(), receiver, this);
|
| + LOG(isolate,
|
| + ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name));
|
| + CustomArguments args(isolate, interceptor->data(), receiver, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = getter(v8::Utils::ToLocal(name_handle), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) {
|
| *attributes = NONE;
|
| return *v8::Utils::OpenHandle(*result);
|
| @@ -7731,16 +7874,17 @@
|
| *receiver_handle,
|
| *name_handle,
|
| attributes);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return result;
|
| }
|
|
|
|
|
| bool JSObject::HasRealNamedProperty(String* key) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, key, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return false;
|
| }
|
|
|
| @@ -7751,10 +7895,11 @@
|
|
|
|
|
| bool JSObject::HasRealElementProperty(uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return false;
|
| }
|
|
|
| @@ -7794,15 +7939,16 @@
|
| }
|
| // All possibilities have been handled above already.
|
| UNREACHABLE();
|
| - return Heap::null_value();
|
| + return heap->null_value();
|
| }
|
|
|
|
|
| bool JSObject::HasRealNamedCallbackProperty(String* key) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, key, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return false;
|
| }
|
|
|
| @@ -8065,51 +8211,6 @@
|
| }
|
|
|
|
|
| -bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
|
| - ASSERT(other->IsNumber());
|
| - return key == static_cast<uint32_t>(other->Number());
|
| -}
|
| -
|
| -
|
| -uint32_t NumberDictionaryShape::Hash(uint32_t key) {
|
| - return ComputeIntegerHash(key);
|
| -}
|
| -
|
| -
|
| -uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) {
|
| - ASSERT(other->IsNumber());
|
| - return ComputeIntegerHash(static_cast<uint32_t>(other->Number()));
|
| -}
|
| -
|
| -
|
| -MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) {
|
| - return Heap::NumberFromUint32(key);
|
| -}
|
| -
|
| -
|
| -bool StringDictionaryShape::IsMatch(String* key, Object* other) {
|
| - // We know that all entries in a hash table had their hash keys created.
|
| - // Use that knowledge to have fast failure.
|
| - if (key->Hash() != String::cast(other)->Hash()) return false;
|
| - return key->Equals(String::cast(other));
|
| -}
|
| -
|
| -
|
| -uint32_t StringDictionaryShape::Hash(String* key) {
|
| - return key->Hash();
|
| -}
|
| -
|
| -
|
| -uint32_t StringDictionaryShape::HashForObject(String* key, Object* other) {
|
| - return String::cast(other)->Hash();
|
| -}
|
| -
|
| -
|
| -MaybeObject* StringDictionaryShape::AsObject(String* key) {
|
| - return key;
|
| -}
|
| -
|
| -
|
| // StringKey simply carries a string object as key.
|
| class StringKey : public HashTableKey {
|
| public:
|
| @@ -8192,7 +8293,7 @@
|
|
|
| MUST_USE_RESULT MaybeObject* AsObject() {
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(3);
|
| + { MaybeObject* maybe_obj = source_->GetHeap()->AllocateFixedArray(3);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* pair = FixedArray::cast(obj);
|
| @@ -8276,7 +8377,8 @@
|
|
|
| MaybeObject* AsObject() {
|
| if (hash_field_ == 0) Hash();
|
| - return Heap::AllocateSymbol(string_, chars_, hash_field_);
|
| + return Isolate::Current()->heap()->AllocateSymbol(
|
| + string_, chars_, hash_field_);
|
| }
|
|
|
| Vector<const char> string_;
|
| @@ -8343,7 +8445,7 @@
|
|
|
| MaybeObject* AsObject() {
|
| if (hash_field_ == 0) Hash();
|
| - return Heap::AllocateAsciiSymbol(string_, hash_field_);
|
| + return HEAP->AllocateAsciiSymbol(string_, hash_field_);
|
| }
|
| };
|
|
|
| @@ -8359,7 +8461,7 @@
|
|
|
| MaybeObject* AsObject() {
|
| if (hash_field_ == 0) Hash();
|
| - return Heap::AllocateTwoByteSymbol(string_, hash_field_);
|
| + return HEAP->AllocateTwoByteSymbol(string_, hash_field_);
|
| }
|
| };
|
|
|
| @@ -8367,7 +8469,8 @@
|
| // SymbolKey carries a string/symbol object as key.
|
| class SymbolKey : public HashTableKey {
|
| public:
|
| - explicit SymbolKey(String* string) : string_(string) { }
|
| + explicit SymbolKey(String* string)
|
| + : string_(string) { }
|
|
|
| bool IsMatch(Object* string) {
|
| return String::cast(string)->Equals(string_);
|
| @@ -8383,8 +8486,9 @@
|
| // Attempt to flatten the string, so that symbols will most often
|
| // be flat strings.
|
| string_ = string_->TryFlattenGetString();
|
| + Heap* heap = string_->GetHeap();
|
| // Transform string to symbol if possible.
|
| - Map* map = Heap::SymbolMapForString(string_);
|
| + Map* map = heap->SymbolMapForString(string_);
|
| if (map != NULL) {
|
| string_->set_map(map);
|
| ASSERT(string_->IsSymbol());
|
| @@ -8392,7 +8496,7 @@
|
| }
|
| // Otherwise allocate a new symbol.
|
| StringInputBuffer buffer(string_);
|
| - return Heap::AllocateInternalSymbol(&buffer,
|
| + return heap->AllocateInternalSymbol(&buffer,
|
| string_->length(),
|
| string_->hash_field());
|
| }
|
| @@ -8431,8 +8535,8 @@
|
| }
|
|
|
| Object* obj;
|
| - { MaybeObject* maybe_obj =
|
| - Heap::AllocateHashTable(EntryToIndex(capacity), pretenure);
|
| + { MaybeObject* maybe_obj = Isolate::Current()->heap()->
|
| + AllocateHashTable(EntryToIndex(capacity), pretenure);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| HashTable::cast(obj)->SetNumberOfElements(0);
|
| @@ -8443,23 +8547,6 @@
|
|
|
|
|
| // Find entry for key otherwise return kNotFound.
|
| -template<typename Shape, typename Key>
|
| -int HashTable<Shape, Key>::FindEntry(Key key) {
|
| - uint32_t capacity = Capacity();
|
| - uint32_t entry = FirstProbe(Shape::Hash(key), capacity);
|
| - uint32_t count = 1;
|
| - // EnsureCapacity will guarantee the hash table is never full.
|
| - while (true) {
|
| - Object* element = KeyAt(entry);
|
| - if (element->IsUndefined()) break; // Empty entry.
|
| - if (!element->IsNull() && Shape::IsMatch(key, element)) return entry;
|
| - entry = NextProbe(entry, count++, capacity);
|
| - }
|
| - return kNotFound;
|
| -}
|
| -
|
| -
|
| -// Find entry for key otherwise return kNotFound.
|
| int StringDictionary::FindEntry(String* key) {
|
| if (!key->IsSymbol()) {
|
| return HashTable<StringDictionaryShape, String*>::FindEntry(key);
|
| @@ -8501,6 +8588,7 @@
|
|
|
| template<typename Shape, typename Key>
|
| MaybeObject* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) {
|
| + Heap* heap = GetHeap();
|
| int capacity = Capacity();
|
| int nof = NumberOfElements() + n;
|
| int nod = NumberOfDeletedElements();
|
| @@ -8514,7 +8602,7 @@
|
|
|
| const int kMinCapacityForPretenure = 256;
|
| bool pretenure =
|
| - (capacity > kMinCapacityForPretenure) && !Heap::InNewSpace(this);
|
| + (capacity > kMinCapacityForPretenure) && !heap->InNewSpace(this);
|
| Object* obj;
|
| { MaybeObject* maybe_obj =
|
| Allocate(nof * 2, pretenure ? TENURED : NOT_TENURED);
|
| @@ -8646,6 +8734,7 @@
|
| // Collates undefined and unexisting elements below limit from position
|
| // zero of the elements. The object stays in Dictionary mode.
|
| MaybeObject* JSObject::PrepareSlowElementsForSort(uint32_t limit) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(HasDictionaryElements());
|
| // Must stay in dictionary mode, either because of requires_slow_elements,
|
| // or because we are not going to sort (and therefore compact) all of the
|
| @@ -8655,7 +8744,7 @@
|
| if (limit > static_cast<uint32_t>(Smi::kMaxValue)) {
|
| // Allocate space for result before we start mutating the object.
|
| Object* new_double;
|
| - { MaybeObject* maybe_new_double = Heap::AllocateHeapNumber(0.0);
|
| + { MaybeObject* maybe_new_double = heap->AllocateHeapNumber(0.0);
|
| if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double;
|
| }
|
| result_double = HeapNumber::cast(new_double);
|
| @@ -8721,7 +8810,7 @@
|
| // allocation. Bailout.
|
| return Smi::FromInt(-1);
|
| }
|
| - new_dict->AddNumberEntry(pos, Heap::undefined_value(), no_details)->
|
| + new_dict->AddNumberEntry(pos, heap->undefined_value(), no_details)->
|
| ToObjectUnchecked();
|
| pos++;
|
| undefs--;
|
| @@ -8744,6 +8833,7 @@
|
| // If the object is in dictionary mode, it is converted to fast elements
|
| // mode.
|
| MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(!HasExternalArrayElements());
|
|
|
| if (HasDictionaryElements()) {
|
| @@ -8762,10 +8852,10 @@
|
| }
|
| Map* new_map = Map::cast(obj);
|
|
|
| - PretenureFlag tenure = Heap::InNewSpace(this) ? NOT_TENURED: TENURED;
|
| + PretenureFlag tenure = heap->InNewSpace(this) ? NOT_TENURED: TENURED;
|
| Object* new_array;
|
| { MaybeObject* maybe_new_array =
|
| - Heap::AllocateFixedArray(dict->NumberOfElements(), tenure);
|
| + heap->AllocateFixedArray(dict->NumberOfElements(), tenure);
|
| if (!maybe_new_array->ToObject(&new_array)) return maybe_new_array;
|
| }
|
| FixedArray* fast_elements = FixedArray::cast(new_array);
|
| @@ -8798,7 +8888,7 @@
|
| // Pessimistically allocate space for return value before
|
| // we start mutating the array.
|
| Object* new_double;
|
| - { MaybeObject* maybe_new_double = Heap::AllocateHeapNumber(0.0);
|
| + { MaybeObject* maybe_new_double = heap->AllocateHeapNumber(0.0);
|
| if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double;
|
| }
|
| result_double = HeapNumber::cast(new_double);
|
| @@ -8892,7 +8982,8 @@
|
|
|
|
|
| template<typename ExternalArrayClass, typename ValueType>
|
| -static MaybeObject* ExternalArrayIntSetter(ExternalArrayClass* receiver,
|
| +static MaybeObject* ExternalArrayIntSetter(Heap* heap,
|
| + ExternalArrayClass* receiver,
|
| uint32_t index,
|
| Object* value) {
|
| ValueType cast_value = 0;
|
| @@ -8910,45 +9001,46 @@
|
| }
|
| receiver->set(index, cast_value);
|
| }
|
| - return Heap::NumberFromInt32(cast_value);
|
| + return heap->NumberFromInt32(cast_value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalByteArray::SetValue(uint32_t index, Object* value) {
|
| return ExternalArrayIntSetter<ExternalByteArray, int8_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalUnsignedByteArray::SetValue(uint32_t index,
|
| Object* value) {
|
| return ExternalArrayIntSetter<ExternalUnsignedByteArray, uint8_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalShortArray::SetValue(uint32_t index,
|
| Object* value) {
|
| return ExternalArrayIntSetter<ExternalShortArray, int16_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalUnsignedShortArray::SetValue(uint32_t index,
|
| Object* value) {
|
| return ExternalArrayIntSetter<ExternalUnsignedShortArray, uint16_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalIntArray::SetValue(uint32_t index, Object* value) {
|
| return ExternalArrayIntSetter<ExternalIntArray, int32_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) {
|
| uint32_t cast_value = 0;
|
| + Heap* heap = GetHeap();
|
| if (index < static_cast<uint32_t>(length())) {
|
| if (value->IsSmi()) {
|
| int int_value = Smi::cast(value)->value();
|
| @@ -8963,12 +9055,13 @@
|
| }
|
| set(index, cast_value);
|
| }
|
| - return Heap::NumberFromUint32(cast_value);
|
| + return heap->NumberFromUint32(cast_value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) {
|
| float cast_value = 0;
|
| + Heap* heap = GetHeap();
|
| if (index < static_cast<uint32_t>(length())) {
|
| if (value->IsSmi()) {
|
| int int_value = Smi::cast(value)->value();
|
| @@ -8983,7 +9076,7 @@
|
| }
|
| set(index, cast_value);
|
| }
|
| - return Heap::AllocateHeapNumber(cast_value);
|
| + return heap->AllocateHeapNumber(cast_value);
|
| }
|
|
|
|
|
| @@ -8996,11 +9089,12 @@
|
|
|
| MaybeObject* GlobalObject::EnsurePropertyCell(String* name) {
|
| ASSERT(!HasFastProperties());
|
| + Heap* heap = GetHeap();
|
| int entry = property_dictionary()->FindEntry(name);
|
| if (entry == StringDictionary::kNotFound) {
|
| Object* cell;
|
| { MaybeObject* maybe_cell =
|
| - Heap::AllocateJSGlobalPropertyCell(Heap::the_hole_value());
|
| + heap->AllocateJSGlobalPropertyCell(heap->the_hole_value());
|
| if (!maybe_cell->ToObject(&cell)) return maybe_cell;
|
| }
|
| PropertyDetails details(NONE, NORMAL);
|
| @@ -9172,9 +9266,10 @@
|
|
|
|
|
| Object* CompilationCacheTable::Lookup(String* src) {
|
| + Heap* heap = GetHeap();
|
| StringKey key(src);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return heap->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
| @@ -9184,16 +9279,17 @@
|
| StrictModeFlag strict_mode) {
|
| StringSharedKey key(src, context->closure()->shared(), strict_mode);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return GetHeap()->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
|
|
| Object* CompilationCacheTable::LookupRegExp(String* src,
|
| JSRegExp::Flags flags) {
|
| + Heap* heap = GetHeap();
|
| RegExpKey key(src, flags);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return heap->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
| @@ -9264,12 +9360,13 @@
|
|
|
|
|
| void CompilationCacheTable::Remove(Object* value) {
|
| + Object* null_value = GetHeap()->null_value();
|
| for (int entry = 0, size = Capacity(); entry < size; entry++) {
|
| int entry_index = EntryToIndex(entry);
|
| int value_index = entry_index + 1;
|
| if (get(value_index) == value) {
|
| - fast_set(this, entry_index, Heap::null_value());
|
| - fast_set(this, value_index, Heap::null_value());
|
| + fast_set(this, entry_index, null_value);
|
| + fast_set(this, value_index, null_value);
|
| ElementRemoved();
|
| }
|
| }
|
| @@ -9312,9 +9409,10 @@
|
|
|
|
|
| Object* MapCache::Lookup(FixedArray* array) {
|
| + Heap* heap = GetHeap();
|
| SymbolsKey key(array);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return heap->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
| @@ -9351,11 +9449,12 @@
|
|
|
| template<typename Shape, typename Key>
|
| MaybeObject* Dictionary<Shape, Key>::GenerateNewEnumerationIndices() {
|
| + Heap* heap = Dictionary<Shape, Key>::GetHeap();
|
| int length = HashTable<Shape, Key>::NumberOfElements();
|
|
|
| // Allocate and initialize iteration order array.
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(length);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(length);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* iteration_order = FixedArray::cast(obj);
|
| @@ -9364,7 +9463,7 @@
|
| }
|
|
|
| // Allocate array with enumeration order.
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(length);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(length);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* enumeration_order = FixedArray::cast(obj);
|
| @@ -9425,8 +9524,9 @@
|
| // Do nothing if the interval [from, to) is empty.
|
| if (from >= to) return;
|
|
|
| + Heap* heap = GetHeap();
|
| int removed_entries = 0;
|
| - Object* sentinel = Heap::null_value();
|
| + Object* sentinel = heap->null_value();
|
| int capacity = Capacity();
|
| for (int i = 0; i < capacity; i++) {
|
| Object* key = KeyAt(i);
|
| @@ -9447,14 +9547,15 @@
|
| template<typename Shape, typename Key>
|
| Object* Dictionary<Shape, Key>::DeleteProperty(int entry,
|
| JSObject::DeleteMode mode) {
|
| + Heap* heap = Dictionary<Shape, Key>::GetHeap();
|
| PropertyDetails details = DetailsAt(entry);
|
| // Ignore attributes if forcing a deletion.
|
| if (details.IsDontDelete() && mode != JSObject::FORCE_DELETION) {
|
| - return Heap::false_value();
|
| + return heap->false_value();
|
| }
|
| - SetEntry(entry, Heap::null_value(), Heap::null_value(), Smi::FromInt(0));
|
| + SetEntry(entry, heap->null_value(), heap->null_value(), Smi::FromInt(0));
|
| HashTable<Shape, Key>::ElementRemoved();
|
| - return Heap::true_value();
|
| + return heap->true_value();
|
| }
|
|
|
|
|
| @@ -9667,6 +9768,7 @@
|
| // Backwards lookup (slow).
|
| template<typename Shape, typename Key>
|
| Object* Dictionary<Shape, Key>::SlowReverseLookup(Object* value) {
|
| + Heap* heap = Dictionary<Shape, Key>::GetHeap();
|
| int capacity = HashTable<Shape, Key>::Capacity();
|
| for (int i = 0; i < capacity; i++) {
|
| Object* k = HashTable<Shape, Key>::KeyAt(i);
|
| @@ -9678,12 +9780,13 @@
|
| if (e == value) return k;
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| MaybeObject* StringDictionary::TransformPropertiesToFastFor(
|
| JSObject* obj, int unused_property_fields) {
|
| + Heap* heap = GetHeap();
|
| // Make sure we preserve dictionary representation if there are too many
|
| // descriptors.
|
| if (NumberOfElements() > DescriptorArray::kMaxNumberOfDescriptors) return obj;
|
| @@ -9713,7 +9816,7 @@
|
| ASSERT(type != FIELD);
|
| instance_descriptor_length++;
|
| if (type == NORMAL &&
|
| - (!value->IsJSFunction() || Heap::InNewSpace(value))) {
|
| + (!value->IsJSFunction() || heap->InNewSpace(value))) {
|
| number_of_fields += 1;
|
| }
|
| }
|
| @@ -9741,7 +9844,7 @@
|
| // Allocate the fixed array for the fields.
|
| Object* fields;
|
| { MaybeObject* maybe_fields =
|
| - Heap::AllocateFixedArray(number_of_allocated_fields);
|
| + heap->AllocateFixedArray(number_of_allocated_fields);
|
| if (!maybe_fields->ToObject(&fields)) return maybe_fields;
|
| }
|
|
|
| @@ -9754,13 +9857,13 @@
|
| Object* value = ValueAt(i);
|
| // Ensure the key is a symbol before writing into the instance descriptor.
|
| Object* key;
|
| - { MaybeObject* maybe_key = Heap::LookupSymbol(String::cast(k));
|
| + { MaybeObject* maybe_key = heap->LookupSymbol(String::cast(k));
|
| if (!maybe_key->ToObject(&key)) return maybe_key;
|
| }
|
| PropertyDetails details = DetailsAt(i);
|
| PropertyType type = details.type();
|
|
|
| - if (value->IsJSFunction() && !Heap::InNewSpace(value)) {
|
| + if (value->IsJSFunction() && !heap->InNewSpace(value)) {
|
| ConstantFunctionDescriptor d(String::cast(key),
|
| JSFunction::cast(value),
|
| details.attributes(),
|
| @@ -9831,11 +9934,12 @@
|
|
|
| // Get the break point info object for this code position.
|
| Object* DebugInfo::GetBreakPointInfo(int code_position) {
|
| + Heap* heap = GetHeap();
|
| // Find the index of the break point info object for this code position.
|
| int index = GetBreakPointInfoIndex(code_position);
|
|
|
| // Return the break point info object if any.
|
| - if (index == kNoBreakPointInfo) return Heap::undefined_value();
|
| + if (index == kNoBreakPointInfo) return heap->undefined_value();
|
| return BreakPointInfo::cast(break_points()->get(index));
|
| }
|
|
|
| @@ -9857,6 +9961,7 @@
|
| int source_position,
|
| int statement_position,
|
| Handle<Object> break_point_object) {
|
| + Isolate* isolate = Isolate::Current();
|
| Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position));
|
| if (!break_point_info->IsUndefined()) {
|
| BreakPointInfo::SetBreakPoint(
|
| @@ -9879,8 +9984,9 @@
|
| Handle<FixedArray> old_break_points =
|
| Handle<FixedArray>(FixedArray::cast(debug_info->break_points()));
|
| Handle<FixedArray> new_break_points =
|
| - Factory::NewFixedArray(old_break_points->length() +
|
| - Debug::kEstimatedNofBreakPointsInFunction);
|
| + isolate->factory()->NewFixedArray(
|
| + old_break_points->length() +
|
| + Debug::kEstimatedNofBreakPointsInFunction);
|
|
|
| debug_info->set_break_points(*new_break_points);
|
| for (int i = 0; i < old_break_points->length(); i++) {
|
| @@ -9891,13 +9997,14 @@
|
| ASSERT(index != kNoBreakPointInfo);
|
|
|
| // Allocate new BreakPointInfo object and set the break point.
|
| - Handle<BreakPointInfo> new_break_point_info =
|
| - Handle<BreakPointInfo>::cast(Factory::NewStruct(BREAK_POINT_INFO_TYPE));
|
| + Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast(
|
| + isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE));
|
| new_break_point_info->set_code_position(Smi::FromInt(code_position));
|
| new_break_point_info->set_source_position(Smi::FromInt(source_position));
|
| new_break_point_info->
|
| set_statement_position(Smi::FromInt(statement_position));
|
| - new_break_point_info->set_break_point_objects(Heap::undefined_value());
|
| + new_break_point_info->set_break_point_objects(
|
| + isolate->heap()->undefined_value());
|
| BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object);
|
| debug_info->break_points()->set(index, *new_break_point_info);
|
| }
|
| @@ -9905,9 +10012,10 @@
|
|
|
| // Get the break point objects for a code position.
|
| Object* DebugInfo::GetBreakPointObjects(int code_position) {
|
| + Heap* heap = GetHeap();
|
| Object* break_point_info = GetBreakPointInfo(code_position);
|
| if (break_point_info->IsUndefined()) {
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
| return BreakPointInfo::cast(break_point_info)->break_point_objects();
|
| }
|
| @@ -9930,7 +10038,8 @@
|
|
|
| Object* DebugInfo::FindBreakPointInfo(Handle<DebugInfo> debug_info,
|
| Handle<Object> break_point_object) {
|
| - if (debug_info->break_points()->IsUndefined()) return Heap::undefined_value();
|
| + Heap* heap = Isolate::Current()->heap();
|
| + if (debug_info->break_points()->IsUndefined()) return heap->undefined_value();
|
| for (int i = 0; i < debug_info->break_points()->length(); i++) {
|
| if (!debug_info->break_points()->get(i)->IsUndefined()) {
|
| Handle<BreakPointInfo> break_point_info =
|
| @@ -9942,7 +10051,7 @@
|
| }
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| @@ -9966,12 +10075,14 @@
|
| // Remove the specified break point object.
|
| void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
|
| Handle<Object> break_point_object) {
|
| + Isolate* isolate = Isolate::Current();
|
| // If there are no break points just ignore.
|
| if (break_point_info->break_point_objects()->IsUndefined()) return;
|
| // If there is a single break point clear it if it is the same.
|
| if (!break_point_info->break_point_objects()->IsFixedArray()) {
|
| if (break_point_info->break_point_objects() == *break_point_object) {
|
| - break_point_info->set_break_point_objects(Heap::undefined_value());
|
| + break_point_info->set_break_point_objects(
|
| + isolate->heap()->undefined_value());
|
| }
|
| return;
|
| }
|
| @@ -9981,7 +10092,7 @@
|
| Handle<FixedArray>(
|
| FixedArray::cast(break_point_info->break_point_objects()));
|
| Handle<FixedArray> new_array =
|
| - Factory::NewFixedArray(old_array->length() - 1);
|
| + isolate->factory()->NewFixedArray(old_array->length() - 1);
|
| int found_count = 0;
|
| for (int i = 0; i < old_array->length(); i++) {
|
| if (old_array->get(i) == *break_point_object) {
|
| @@ -10008,7 +10119,7 @@
|
| if (break_point_info->break_point_objects() == *break_point_object) return;
|
| // If there was one break point object before replace with array.
|
| if (!break_point_info->break_point_objects()->IsFixedArray()) {
|
| - Handle<FixedArray> array = Factory::NewFixedArray(2);
|
| + Handle<FixedArray> array = FACTORY->NewFixedArray(2);
|
| array->set(0, break_point_info->break_point_objects());
|
| array->set(1, *break_point_object);
|
| break_point_info->set_break_point_objects(*array);
|
| @@ -10019,7 +10130,7 @@
|
| Handle<FixedArray>(
|
| FixedArray::cast(break_point_info->break_point_objects()));
|
| Handle<FixedArray> new_array =
|
| - Factory::NewFixedArray(old_array->length() + 1);
|
| + FACTORY->NewFixedArray(old_array->length() + 1);
|
| for (int i = 0; i < old_array->length(); i++) {
|
| // If the break point was there before just ignore.
|
| if (old_array->get(i) == *break_point_object) return;
|
|
|