Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: src/objects.cc

Issue 139973004: A64: Synchronize with r15814. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 7b06b8732ad03928d97d3dfcf16483b7633a39c5..2ecc57b5de96c83ab19bce37a8bdf012a94f7c91 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -715,46 +715,54 @@ MaybeObject* JSObject::SetNormalizedProperty(Name* name,
}
-MaybeObject* JSObject::DeleteNormalizedProperty(Name* name, DeleteMode mode) {
- ASSERT(!HasFastProperties());
- NameDictionary* dictionary = property_dictionary();
- int entry = dictionary->FindEntry(name);
+// TODO(mstarzinger): Temporary wrapper until target is handlified.
+Handle<NameDictionary> NameDictionaryShrink(Handle<NameDictionary> dict,
+ Handle<Name> name) {
+ CALL_HEAP_FUNCTION(dict->GetIsolate(), dict->Shrink(*name), NameDictionary);
+}
+
+
+static void CellSetValueInferType(Handle<PropertyCell> cell,
+ Handle<Object> value) {
+ CALL_HEAP_FUNCTION_VOID(cell->GetIsolate(), cell->SetValueInferType(*value));
+}
+
+
+Handle<Object> JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
+ Handle<Name> name,
+ DeleteMode mode) {
+ ASSERT(!object->HasFastProperties());
+ Isolate* isolate = object->GetIsolate();
+ Handle<NameDictionary> dictionary(object->property_dictionary());
+ int entry = dictionary->FindEntry(*name);
if (entry != NameDictionary::kNotFound) {
// If we have a global object set the cell to the hole.
- if (IsGlobalObject()) {
+ if (object->IsGlobalObject()) {
PropertyDetails details = dictionary->DetailsAt(entry);
if (details.IsDontDelete()) {
- if (mode != FORCE_DELETION) return GetHeap()->false_value();
+ if (mode != FORCE_DELETION) return isolate->factory()->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
// the hole value.
- Map* new_map;
- MaybeObject* maybe_new_map = map()->CopyDropDescriptors();
- if (!maybe_new_map->To(&new_map)) return maybe_new_map;
-
+ Handle<Map> new_map = Map::CopyDropDescriptors(handle(object->map()));
ASSERT(new_map->is_dictionary_map());
- set_map(new_map);
+ object->set_map(*new_map);
}
- PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry));
- MaybeObject* maybe_type =
- cell->SetValueInferType(cell->GetHeap()->the_hole_value());
- if (maybe_type->IsFailure()) return maybe_type;
+ Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry)));
+ CellSetValueInferType(cell, isolate->factory()->the_hole_value());
dictionary->DetailsAtPut(entry, details.AsDeleted());
} else {
- Object* deleted = dictionary->DeleteProperty(entry, mode);
- if (deleted == GetHeap()->true_value()) {
- FixedArray* new_properties = NULL;
- MaybeObject* maybe_properties = dictionary->Shrink(name);
- if (!maybe_properties->To(&new_properties)) {
- return maybe_properties;
- }
- set_properties(new_properties);
+ Handle<Object> deleted(dictionary->DeleteProperty(entry, mode), isolate);
+ if (*deleted == isolate->heap()->true_value()) {
+ Handle<NameDictionary> new_properties =
+ NameDictionaryShrink(dictionary, name);
+ object->set_properties(*new_properties);
}
return deleted;
}
}
- return GetHeap()->true_value();
+ return isolate->factory()->true_value();
}
@@ -1335,6 +1343,10 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
accumulator->Add("<JS WeakMap>");
break;
}
+ case JS_WEAK_SET_TYPE: {
+ accumulator->Add("<JS WeakSet>");
+ break;
+ }
case JS_REGEXP_TYPE: {
accumulator->Add("<JS RegExp>");
break;
@@ -1645,6 +1657,7 @@ void HeapObject::IterateBody(InstanceType type, int object_size,
case JS_SET_TYPE:
case JS_MAP_TYPE:
case JS_WEAK_MAP_TYPE:
+ case JS_WEAK_SET_TYPE:
case JS_REGEXP_TYPE:
case JS_GLOBAL_PROXY_TYPE:
case JS_GLOBAL_OBJECT_TYPE:
@@ -1706,7 +1719,11 @@ void HeapObject::IterateBody(InstanceType type, int object_size,
case NAME##_TYPE:
STRUCT_LIST(MAKE_STRUCT_CASE)
#undef MAKE_STRUCT_CASE
- StructBodyDescriptor::IterateBody(this, object_size, v);
+ if (type == ALLOCATION_SITE_TYPE) {
+ AllocationSite::BodyDescriptor::IterateBody(this, v);
+ } else {
+ StructBodyDescriptor::IterateBody(this, object_size, v);
+ }
break;
default:
PrintF("Unknown type: %d\n", type);
@@ -3531,43 +3548,38 @@ MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyViaPrototypesWithHandler(
}
-MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler(
- Name* name_raw, DeleteMode mode) {
- Isolate* isolate = GetIsolate();
- HandleScope scope(isolate);
- Handle<JSProxy> receiver(this);
- Handle<Object> name(name_raw, isolate);
+Handle<Object> JSProxy::DeletePropertyWithHandler(
+ Handle<JSProxy> object, Handle<Name> name, DeleteMode mode) {
+ Isolate* isolate = object->GetIsolate();
// TODO(rossberg): adjust once there is a story for symbols vs proxies.
- if (name->IsSymbol()) return isolate->heap()->false_value();
+ if (name->IsSymbol()) return isolate->factory()->false_value();
Handle<Object> args[] = { name };
- Handle<Object> result = CallTrap(
- "delete", Handle<Object>(), ARRAY_SIZE(args), args);
- if (isolate->has_pending_exception()) return Failure::Exception();
+ Handle<Object> result = object->CallTrap(
+ "delete", Handle<Object>(), ARRAY_SIZE(args), args);
+ if (isolate->has_pending_exception()) return Handle<Object>();
bool result_bool = result->BooleanValue();
if (mode == STRICT_DELETION && !result_bool) {
- Handle<Object> handler(receiver->handler(), isolate);
+ Handle<Object> handler(object->handler(), isolate);
Handle<String> trap_name = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("delete"));
Handle<Object> args[] = { handler, trap_name };
Handle<Object> error = isolate->factory()->NewTypeError(
"handler_failed", HandleVector(args, ARRAY_SIZE(args)));
isolate->Throw(*error);
- return Failure::Exception();
+ return Handle<Object>();
}
- return isolate->heap()->ToBoolean(result_bool);
+ return isolate->factory()->ToBoolean(result_bool);
}
-MUST_USE_RESULT MaybeObject* JSProxy::DeleteElementWithHandler(
- uint32_t index,
- DeleteMode mode) {
- Isolate* isolate = GetIsolate();
- HandleScope scope(isolate);
+Handle<Object> JSProxy::DeleteElementWithHandler(
+ Handle<JSProxy> object, uint32_t index, DeleteMode mode) {
+ Isolate* isolate = object->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
- return JSProxy::DeletePropertyWithHandler(*name, mode);
+ return JSProxy::DeletePropertyWithHandler(object, name, mode);
}
@@ -3600,17 +3612,24 @@ MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler(
// Convert result to PropertyAttributes.
Handle<String> enum_n = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("enumerable"));
+ STATIC_ASCII_VECTOR("enumerable_"));
Handle<Object> enumerable(v8::internal::GetProperty(isolate, desc, enum_n));
if (isolate->has_pending_exception()) return NONE;
Handle<String> conf_n = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("configurable"));
+ STATIC_ASCII_VECTOR("configurable_"));
Handle<Object> configurable(v8::internal::GetProperty(isolate, desc, conf_n));
if (isolate->has_pending_exception()) return NONE;
Handle<String> writ_n = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("writable"));
+ STATIC_ASCII_VECTOR("writable_"));
Handle<Object> writable(v8::internal::GetProperty(isolate, desc, writ_n));
if (isolate->has_pending_exception()) return NONE;
+ if (!writable->BooleanValue()) {
+ Handle<String> set_n = isolate->factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("set_"));
+ Handle<Object> setter(v8::internal::GetProperty(isolate, desc, set_n));
+ if (isolate->has_pending_exception()) return NONE;
+ writable = isolate->factory()->ToBoolean(!setter->IsUndefined());
+ }
if (configurable->IsFalse()) {
Handle<String> trap = isolate->factory()->InternalizeOneByteString(
@@ -4968,52 +4987,52 @@ MaybeObject* JSObject::SetHiddenPropertiesHashTable(Object* value) {
}
-MaybeObject* JSObject::DeletePropertyPostInterceptor(Name* name,
- DeleteMode mode) {
+Handle<Object> JSObject::DeletePropertyPostInterceptor(Handle<JSObject> object,
+ Handle<Name> name,
+ DeleteMode mode) {
// Check local property, ignore interceptor.
- LookupResult result(GetIsolate());
- LocalLookupRealNamedProperty(name, &result);
- if (!result.IsFound()) return GetHeap()->true_value();
+ Isolate* isolate = object->GetIsolate();
+ LookupResult result(isolate);
+ object->LocalLookupRealNamedProperty(*name, &result);
+ if (!result.IsFound()) return isolate->factory()->true_value();
// Normalize object if needed.
- Object* obj;
- { MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
- if (!maybe_obj->ToObject(&obj)) return maybe_obj;
- }
+ NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0);
- return DeleteNormalizedProperty(name, mode);
+ return DeleteNormalizedProperty(object, name, mode);
}
-MaybeObject* JSObject::DeletePropertyWithInterceptor(Name* name) {
+Handle<Object> JSObject::DeletePropertyWithInterceptor(Handle<JSObject> object,
+ Handle<Name> name) {
+ Isolate* isolate = object->GetIsolate();
+
// TODO(rossberg): Support symbols in the API.
- if (name->IsSymbol()) return GetHeap()->false_value();
+ if (name->IsSymbol()) return isolate->factory()->false_value();
- Isolate* isolate = GetIsolate();
- HandleScope scope(isolate);
- Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
- Handle<String> name_handle(String::cast(name));
- Handle<JSObject> this_handle(this);
+ Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor());
if (!interceptor->deleter()->IsUndefined()) {
v8::NamedPropertyDeleter deleter =
v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter());
LOG(isolate,
- ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name));
- PropertyCallbackArguments args(isolate, interceptor->data(), this, this);
+ ApiNamedPropertyAccess("interceptor-named-delete", *object, *name));
+ PropertyCallbackArguments args(
+ isolate, interceptor->data(), *object, *object);
v8::Handle<v8::Boolean> result =
- args.Call(deleter, v8::Utils::ToLocal(name_handle));
- RETURN_IF_SCHEDULED_EXCEPTION(isolate);
+ args.Call(deleter, v8::Utils::ToLocal(Handle<String>::cast(name)));
+ RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
if (!result.IsEmpty()) {
ASSERT(result->IsBoolean());
Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
result_internal->VerifyApiCallResultType();
- return *result_internal;
+ // Rebox CustomArguments::kReturnValueOffset before returning.
+ return handle(*result_internal, isolate);
}
}
- MaybeObject* raw_result =
- this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION);
- RETURN_IF_SCHEDULED_EXCEPTION(isolate);
- return raw_result;
+ Handle<Object> result =
+ DeletePropertyPostInterceptor(object, name, NORMAL_DELETION);
+ RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
+ return result;
}
@@ -5050,9 +5069,10 @@ MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) {
Handle<Object> JSObject::DeleteElement(Handle<JSObject> obj,
- uint32_t index) {
+ uint32_t index,
+ DeleteMode mode) {
CALL_HEAP_FUNCTION(obj->GetIsolate(),
- obj->DeleteElement(index, JSObject::NORMAL_DELETION),
+ obj->DeleteElement(index, mode),
Object);
}
@@ -5124,108 +5144,99 @@ MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
}
-Handle<Object> JSObject::DeleteProperty(Handle<JSObject> obj,
- Handle<Name> prop) {
- CALL_HEAP_FUNCTION(obj->GetIsolate(),
- obj->DeleteProperty(*prop, JSObject::NORMAL_DELETION),
- Object);
-}
-
-
-MaybeObject* JSObject::DeleteProperty(Name* name, DeleteMode mode) {
- Isolate* isolate = GetIsolate();
+Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object,
+ Handle<Name> name,
+ DeleteMode mode) {
+ Isolate* isolate = object->GetIsolate();
// ECMA-262, 3rd, 8.6.2.5
ASSERT(name->IsName());
// Check access rights if needed.
- if (IsAccessCheckNeeded() &&
- !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
- isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
- RETURN_IF_SCHEDULED_EXCEPTION(isolate);
- return isolate->heap()->false_value();
+ if (object->IsAccessCheckNeeded() &&
+ !isolate->MayNamedAccess(*object, *name, v8::ACCESS_DELETE)) {
+ isolate->ReportFailedAccessCheck(*object, v8::ACCESS_DELETE);
+ RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
+ return isolate->factory()->false_value();
}
- if (IsJSGlobalProxy()) {
- Object* proto = GetPrototype();
- if (proto->IsNull()) return isolate->heap()->false_value();
+ if (object->IsJSGlobalProxy()) {
+ Object* proto = object->GetPrototype();
+ if (proto->IsNull()) return isolate->factory()->false_value();
ASSERT(proto->IsJSGlobalObject());
- return JSGlobalObject::cast(proto)->DeleteProperty(name, mode);
+ return JSGlobalObject::DeleteProperty(
+ handle(JSGlobalObject::cast(proto)), name, mode);
}
uint32_t index = 0;
if (name->AsArrayIndex(&index)) {
- return DeleteElement(index, mode);
+ return DeleteElement(object, index, mode);
}
LookupResult lookup(isolate);
- LocalLookup(name, &lookup, true);
- if (!lookup.IsFound()) return isolate->heap()->true_value();
+ object->LocalLookup(*name, &lookup, true);
+ if (!lookup.IsFound()) return isolate->factory()->true_value();
// Ignore attributes if forcing a deletion.
if (lookup.IsDontDelete() && mode != FORCE_DELETION) {
if (mode == STRICT_DELETION) {
// Deleting a non-configurable property in strict mode.
- HandleScope scope(isolate);
- Handle<Object> args[2] = { Handle<Object>(name, isolate),
- Handle<Object>(this, isolate) };
- return isolate->Throw(*isolate->factory()->NewTypeError(
- "strict_delete_property", HandleVector(args, 2)));
+ Handle<Object> args[2] = { name, object };
+ Handle<Object> error = isolate->factory()->NewTypeError(
+ "strict_delete_property", HandleVector(args, ARRAY_SIZE(args)));
+ isolate->Throw(*error);
+ return Handle<Object>();
}
- return isolate->heap()->false_value();
+ return isolate->factory()->false_value();
}
- // From this point on everything needs to be handlified.
- HandleScope scope(isolate);
- Handle<JSObject> self(this);
- Handle<Name> hname(name);
-
Handle<Object> old_value = isolate->factory()->the_hole_value();
- bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
+ bool is_observed = FLAG_harmony_observation && object->map()->is_observed();
if (is_observed && lookup.IsDataProperty()) {
- old_value = Object::GetProperty(self, hname);
+ old_value = Object::GetProperty(object, name);
}
- MaybeObject* result;
+ Handle<Object> result;
// Check for interceptor.
if (lookup.IsInterceptor()) {
// Skip interceptor if forcing a deletion.
if (mode == FORCE_DELETION) {
- result = self->DeletePropertyPostInterceptor(*hname, mode);
+ result = DeletePropertyPostInterceptor(object, name, mode);
} else {
- result = self->DeletePropertyWithInterceptor(*hname);
+ result = DeletePropertyWithInterceptor(object, name);
}
} else {
// Normalize object if needed.
- Object* obj;
- result = self->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
- if (!result->To(&obj)) return result;
+ NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0);
// Make sure the properties are normalized before removing the entry.
- result = self->DeleteNormalizedProperty(*hname, mode);
+ result = DeleteNormalizedProperty(object, name, mode);
}
- Handle<Object> hresult;
- if (!result->ToHandle(&hresult, isolate)) return result;
-
- if (is_observed && !self->HasLocalProperty(*hname)) {
- EnqueueChangeRecord(self, "deleted", hname, old_value);
+ if (is_observed && !object->HasLocalProperty(*name)) {
+ EnqueueChangeRecord(object, "deleted", name, old_value);
}
- return *hresult;
+ return result;
}
-MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) {
- if (IsJSProxy()) {
- return JSProxy::cast(this)->DeleteElementWithHandler(index, mode);
+Handle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object,
+ uint32_t index,
+ DeleteMode mode) {
+ if (object->IsJSProxy()) {
+ return JSProxy::DeleteElementWithHandler(
+ Handle<JSProxy>::cast(object), index, mode);
}
- return JSObject::cast(this)->DeleteElement(index, mode);
+ return JSObject::DeleteElement(Handle<JSObject>::cast(object), index, mode);
}
-MaybeObject* JSReceiver::DeleteProperty(Name* name, DeleteMode mode) {
- if (IsJSProxy()) {
- return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode);
+Handle<Object> JSReceiver::DeleteProperty(Handle<JSReceiver> object,
+ Handle<Name> name,
+ DeleteMode mode) {
+ if (object->IsJSProxy()) {
+ return JSProxy::DeletePropertyWithHandler(
+ Handle<JSProxy>::cast(object), name, mode);
}
- return JSObject::cast(this)->DeleteProperty(name, mode);
+ return JSObject::DeleteProperty(Handle<JSObject>::cast(object), name, mode);
}
@@ -6507,6 +6518,11 @@ MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode,
}
+Handle<Map> Map::CopyDropDescriptors(Handle<Map> map) {
+ CALL_HEAP_FUNCTION(map->GetIsolate(), map->CopyDropDescriptors(), Map);
+}
+
+
MaybeObject* Map::CopyDropDescriptors() {
Map* result;
MaybeObject* maybe_result = RawCopy(instance_size());
@@ -8916,24 +8932,24 @@ Handle<String> SeqString::Truncate(Handle<SeqString> string, int new_length) {
}
-AllocationSiteInfo* AllocationSiteInfo::FindForJSObject(JSObject* object) {
- // Currently, AllocationSiteInfo objects are only allocated immediately
+AllocationMemento* AllocationMemento::FindForJSObject(JSObject* object) {
+ // Currently, AllocationMemento objects are only allocated immediately
// after JSArrays in NewSpace, and detecting whether a JSArray has one
// involves carefully checking the object immediately after the JSArray
- // (if there is one) to see if it's an AllocationSiteInfo.
+ // (if there is one) to see if it's an AllocationMemento.
if (FLAG_track_allocation_sites && object->GetHeap()->InNewSpace(object)) {
Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) +
object->Size();
- if ((ptr_end + AllocationSiteInfo::kSize) <=
+ if ((ptr_end + AllocationMemento::kSize) <=
object->GetHeap()->NewSpaceTop()) {
// There is room in newspace for allocation info. Do we have some?
- Map** possible_allocation_site_info_map =
+ Map** possible_allocation_memento_map =
reinterpret_cast<Map**>(ptr_end);
- if (*possible_allocation_site_info_map ==
- object->GetHeap()->allocation_site_info_map()) {
- AllocationSiteInfo* info = AllocationSiteInfo::cast(
+ if (*possible_allocation_memento_map ==
+ object->GetHeap()->allocation_memento_map()) {
+ AllocationMemento* memento = AllocationMemento::cast(
reinterpret_cast<Object*>(ptr_end + 1));
- return info;
+ return memento;
}
}
}
@@ -9528,57 +9544,53 @@ Handle<Object> CacheInitialJSArrayMaps(Handle<Context> native_context,
}
-MaybeObject* JSFunction::SetInstancePrototype(Object* value) {
+void JSFunction::SetInstancePrototype(Handle<JSFunction> function,
+ Handle<Object> value) {
ASSERT(value->IsJSReceiver());
- Heap* heap = GetHeap();
// First some logic for the map of the prototype to make sure it is in fast
// mode.
if (value->IsJSObject()) {
- MaybeObject* ok = JSObject::cast(value)->OptimizeAsPrototype();
- if (ok->IsFailure()) return ok;
+ JSObject::OptimizeAsPrototype(Handle<JSObject>::cast(value));
}
// Now some logic for the maps of the objects that are created by using this
// function as a constructor.
- if (has_initial_map()) {
+ if (function->has_initial_map()) {
// If the function has allocated the initial map replace it with a
// copy containing the new prototype. Also complete any in-object
// slack tracking that is in progress at this point because it is
// still tracking the old copy.
- if (shared()->IsInobjectSlackTrackingInProgress()) {
- shared()->CompleteInobjectSlackTracking();
+ if (function->shared()->IsInobjectSlackTrackingInProgress()) {
+ function->shared()->CompleteInobjectSlackTracking();
}
- Map* new_map;
- MaybeObject* maybe_object = initial_map()->Copy();
- if (!maybe_object->To(&new_map)) return maybe_object;
- new_map->set_prototype(value);
+ Handle<Map> new_map = Map::Copy(handle(function->initial_map()));
+ new_map->set_prototype(*value);
// If the function is used as the global Array function, cache the
// initial map (and transitioned versions) in the native context.
- Context* native_context = context()->native_context();
+ Context* native_context = function->context()->native_context();
Object* array_function = native_context->get(Context::ARRAY_FUNCTION_INDEX);
if (array_function->IsJSFunction() &&
- this == JSFunction::cast(array_function)) {
- MaybeObject* ok = CacheInitialJSArrayMaps(native_context, new_map);
- if (ok->IsFailure()) return ok;
+ *function == JSFunction::cast(array_function)) {
+ CacheInitialJSArrayMaps(handle(native_context), new_map);
}
- set_initial_map(new_map);
+ function->set_initial_map(*new_map);
} else {
// Put the value in the initial map field until an initial map is
// needed. At that point, a new initial map is created and the
// prototype is put into the initial map where it belongs.
- set_prototype_or_initial_map(value);
+ function->set_prototype_or_initial_map(*value);
}
- heap->ClearInstanceofCache();
- return value;
+ function->GetHeap()->ClearInstanceofCache();
}
-MaybeObject* JSFunction::SetPrototype(Object* value) {
- ASSERT(should_have_prototype());
- Object* construct_prototype = value;
+void JSFunction::SetPrototype(Handle<JSFunction> function,
+ Handle<Object> value) {
+ ASSERT(function->should_have_prototype());
+ Handle<Object> construct_prototype = value;
// If the value is not a JSReceiver, store the value in the map's
// constructor field so it can be accessed. Also, set the prototype
@@ -9588,22 +9600,20 @@ MaybeObject* JSFunction::SetPrototype(Object* value) {
// Copy the map so this does not affect unrelated functions.
// Remove map transitions because they point to maps with a
// different prototype.
- Map* new_map;
- MaybeObject* maybe_new_map = map()->Copy();
- if (!maybe_new_map->To(&new_map)) return maybe_new_map;
+ Handle<Map> new_map = Map::Copy(handle(function->map()));
- Heap* heap = new_map->GetHeap();
- set_map(new_map);
- new_map->set_constructor(value);
+ function->set_map(*new_map);
+ new_map->set_constructor(*value);
new_map->set_non_instance_prototype(true);
- construct_prototype =
- heap->isolate()->context()->native_context()->
- initial_object_prototype();
+ Isolate* isolate = new_map->GetIsolate();
+ construct_prototype = handle(
+ isolate->context()->native_context()->initial_object_prototype(),
+ isolate);
} else {
- map()->set_non_instance_prototype(false);
+ function->map()->set_non_instance_prototype(false);
}
- return SetInstancePrototype(construct_prototype);
+ return SetInstancePrototype(function, construct_prototype);
}
@@ -9642,8 +9652,16 @@ Context* JSFunction::NativeContextFromLiterals(FixedArray* literals) {
bool JSFunction::PassesHydrogenFilter() {
String* name = shared()->DebugName();
- if (*FLAG_hydrogen_filter != '\0') {
+ // The filter string is a pattern that matches functions in this way:
+ // "*" all; the default
+ // "-" all but the top-level function
+ // "-name" all but the function "name"
+ // "" only the top-level function
+ // "name" only the function "name"
+ // "name*" only functions starting with "name"
+ if (*FLAG_hydrogen_filter != '*') {
Vector<const char> filter = CStrVector(FLAG_hydrogen_filter);
+ if (filter.length() == 0) return name->length() == 0;
if (filter[0] != '-' && name->IsUtf8EqualTo(filter)) return true;
if (filter[0] == '-' &&
!name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
@@ -10786,7 +10804,8 @@ void Code::Disassemble(const char* name, FILE* out) {
for (uint32_t i = 0; i < table_length; ++i) {
uint32_t ast_id = Memory::uint32_at(back_edge_cursor);
uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize);
- uint8_t loop_depth = Memory::uint8_at(back_edge_cursor + 2 * kIntSize);
+ uint32_t loop_depth = Memory::uint32_at(back_edge_cursor +
+ 2 * kIntSize);
PrintF(out, "%6u %9u %10u\n", ast_id, pc_offset, loop_depth);
back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize;
}
@@ -12371,13 +12390,13 @@ MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
return this;
}
- AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this);
- if (info == NULL || !info->IsValid()) {
+ AllocationMemento* memento = AllocationMemento::FindForJSObject(this);
+ if (memento == NULL || !memento->IsValid()) {
return this;
}
// Walk through to the Allocation Site
- AllocationSite* site = info->GetAllocationSite();
+ AllocationSite* site = memento->GetAllocationSite();
if (site->IsLiteralSite()) {
JSArray* transition_info = JSArray::cast(site->transition_info());
ElementsKind kind = transition_info->GetElementsKind();
@@ -15899,9 +15918,9 @@ Type* PropertyCell::UpdateType(Handle<PropertyCell> cell,
Handle<Object> value) {
Isolate* isolate = cell->GetIsolate();
Handle<Type> old_type(cell->type(), isolate);
- Handle<Type> new_type((value->IsSmi() || value->IsUndefined())
- ? Type::Constant(value, isolate)
- : Type::Any(), isolate);
+ Handle<Type> new_type(value->IsConsString() || value->IsTheHole()
+ ? Type::Any()
+ : Type::Constant(value, isolate), isolate);
if (new_type->Is(old_type)) {
return *old_type;
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698