From: mstarzinger@chromium.org Date: Thu, 12 Sep 2013 13:27:42 +0000 (+0000) Subject: Use trampoline or handlified JSObject::SetLocalPropertyIgnoreAttributes. X-Git-Tag: upstream/4.7.83~12528 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c18fbc229405dd4433d782705831f8a3ecf3380;p=platform%2Fupstream%2Fv8.git Use trampoline or handlified JSObject::SetLocalPropertyIgnoreAttributes. R=verwaest@chromium.org Committed: http://code.google.com/p/v8/source/detail?r=16642 Review URL: https://codereview.chromium.org/24093002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16686 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/accessors.cc b/src/accessors.cc index f8cb0c8..669c02b 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -113,7 +113,7 @@ MaybeObject* Accessors::ArraySetLength(Isolate* isolate, // object does not have a 'length' property. Calling SetProperty // causes an infinite loop. if (!object->IsJSArray()) { - return object->SetLocalPropertyIgnoreAttributes( + return object->SetLocalPropertyIgnoreAttributesTrampoline( isolate->heap()->length_string(), value, NONE); } @@ -531,9 +531,8 @@ MaybeObject* Accessors::FunctionSetPrototype(Isolate* isolate, if (function_raw == NULL) return heap->undefined_value(); if (!function_raw->should_have_prototype()) { // Since we hit this accessor, object will have no prototype property. - return object->SetLocalPropertyIgnoreAttributes(heap->prototype_string(), - value_raw, - NONE); + return object->SetLocalPropertyIgnoreAttributesTrampoline( + heap->prototype_string(), value_raw, NONE); } HandleScope scope(isolate); diff --git a/src/heap.cc b/src/heap.cc index 0455a84..24e4039 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -4371,7 +4371,7 @@ MaybeObject* Heap::AllocateFunctionPrototype(JSFunction* function) { if (!function->shared()->is_generator()) { MaybeObject* maybe_failure = - JSObject::cast(prototype)->SetLocalPropertyIgnoreAttributes( + JSObject::cast(prototype)->SetLocalPropertyIgnoreAttributesTrampoline( constructor_string(), function, DONT_ENUM); if (maybe_failure->IsFailure()) return maybe_failure; } diff --git a/src/objects.h b/src/objects.h index 0b8a9b9..1e324e6 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2188,13 +2188,6 @@ class JSObject: public JSReceiver { inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); // Can cause GC. - MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( - Name* key, - Object* value, - PropertyAttributes attributes, - ValueType value_type = OPTIMAL_REPRESENTATION, - StoreMode mode = ALLOW_AS_CONSTANT, - ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributesTrampoline( Name* key, Object* value, @@ -2736,6 +2729,15 @@ class JSObject: public JSReceiver { friend class DictionaryElementsAccessor; friend class JSReceiver; + // TODO(mstarzinger): Soon to be handlified. + MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( + Name* key, + Object* value, + PropertyAttributes attributes, + ValueType value_type = OPTIMAL_REPRESENTATION, + StoreMode mode = ALLOW_AS_CONSTANT, + ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); + MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, Object* structure, uint32_t index, diff --git a/src/runtime.cc b/src/runtime.cc index 912cfce..c09fb1d 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -2276,9 +2276,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { LookupResult lookup(isolate); global->LocalLookup(*name, &lookup); if (!lookup.IsFound()) { - return global->SetLocalPropertyIgnoreAttributes(*name, - *value, - attributes); + HandleScope handle_scope(isolate); + Handle global(isolate->context()->global_object()); + RETURN_IF_EMPTY_HANDLE( + isolate, + JSObject::SetLocalPropertyIgnoreAttributes(global, name, value, + attributes)); + return *value; } if (!lookup.IsReadOnly()) { @@ -2495,41 +2499,41 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { - SealHandleScope shs(isolate); + HandleScope scope(isolate); DisallowHeapAllocation no_allocation; ASSERT(args.length() == 5); - CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); - CONVERT_ARG_CHECKED(String, source, 1); + CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); + CONVERT_ARG_HANDLE_CHECKED(String, source, 1); // If source is the empty string we set it to "(?:)" instead as // suggested by ECMA-262, 5th, section 15.10.4.1. - if (source->length() == 0) source = isolate->heap()->query_colon_string(); + if (source->length() == 0) source = isolate->factory()->query_colon_string(); - Object* global = args[2]; - if (!global->IsTrue()) global = isolate->heap()->false_value(); + CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); + if (!global->IsTrue()) global = isolate->factory()->false_value(); - Object* ignoreCase = args[3]; - if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value(); + CONVERT_ARG_HANDLE_CHECKED(Object, ignoreCase, 3); + if (!ignoreCase->IsTrue()) ignoreCase = isolate->factory()->false_value(); - Object* multiline = args[4]; - if (!multiline->IsTrue()) multiline = isolate->heap()->false_value(); + CONVERT_ARG_HANDLE_CHECKED(Object, multiline, 4); + if (!multiline->IsTrue()) multiline = isolate->factory()->false_value(); Map* map = regexp->map(); Object* constructor = map->constructor(); if (constructor->IsJSFunction() && JSFunction::cast(constructor)->initial_map() == map) { // If we still have the original map, set in-object properties directly. - regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, source); + regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source); // Both true and false are immovable immortal objects so no need for write // barrier. regexp->InObjectPropertyAtPut( - JSRegExp::kGlobalFieldIndex, global, SKIP_WRITE_BARRIER); + JSRegExp::kGlobalFieldIndex, *global, SKIP_WRITE_BARRIER); regexp->InObjectPropertyAtPut( - JSRegExp::kIgnoreCaseFieldIndex, ignoreCase, SKIP_WRITE_BARRIER); + JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase, SKIP_WRITE_BARRIER); regexp->InObjectPropertyAtPut( - JSRegExp::kMultilineFieldIndex, multiline, SKIP_WRITE_BARRIER); + JSRegExp::kMultilineFieldIndex, *multiline, SKIP_WRITE_BARRIER); regexp->InObjectPropertyAtPut( JSRegExp::kLastIndexFieldIndex, Smi::FromInt(0), SKIP_WRITE_BARRIER); - return regexp; + return *regexp; } // Map has changed, so use generic, but slower, method. @@ -2537,34 +2541,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { static_cast(READ_ONLY | DONT_ENUM | DONT_DELETE); PropertyAttributes writable = static_cast(DONT_ENUM | DONT_DELETE); - Heap* heap = isolate->heap(); - MaybeObject* result; - result = regexp->SetLocalPropertyIgnoreAttributes(heap->source_string(), - source, - final); - // TODO(jkummerow): Turn these back into ASSERTs when we can be certain - // that it never fires in Release mode in the wild. - CHECK(!result->IsFailure()); - result = regexp->SetLocalPropertyIgnoreAttributes(heap->global_string(), - global, - final); - CHECK(!result->IsFailure()); - result = - regexp->SetLocalPropertyIgnoreAttributes(heap->ignore_case_string(), - ignoreCase, - final); - CHECK(!result->IsFailure()); - result = regexp->SetLocalPropertyIgnoreAttributes(heap->multiline_string(), - multiline, - final); - CHECK(!result->IsFailure()); - result = - regexp->SetLocalPropertyIgnoreAttributes(heap->last_index_string(), - Smi::FromInt(0), - writable); - CHECK(!result->IsFailure()); - USE(result); - return regexp; + Handle zero(Smi::FromInt(0), isolate); + Factory* factory = isolate->factory(); + CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->source_string(), source, final)); + CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->global_string(), global, final)); + CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->ignore_case_string(), ignoreCase, final)); + CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->multiline_string(), multiline, final)); + CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->last_index_string(), zero, writable)); + return *regexp; } @@ -5064,9 +5053,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); // Use IgnoreAttributes version since a readonly property may be // overridden and SetProperty does not allow this. - return js_object->SetLocalPropertyIgnoreAttributes(*name, - *obj_value, - attr); + Handle result = JSObject::SetLocalPropertyIgnoreAttributes( + js_object, name, obj_value, attr); + RETURN_IF_EMPTY_HANDLE(isolate, result); + return *result; } return Runtime::ForceSetObjectProperty(isolate, @@ -5252,7 +5242,10 @@ MaybeObject* Runtime::ForceSetObjectProperty(Isolate* isolate, index, *value, attr, kNonStrictMode, false, DEFINE_PROPERTY); } else { if (name->IsString()) Handle::cast(name)->TryFlatten(); - return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr); + Handle result = JSObject::SetLocalPropertyIgnoreAttributes( + js_object, name, value, attr); + RETURN_IF_EMPTY_HANDLE(isolate, result); + return *result; } } @@ -5267,7 +5260,10 @@ MaybeObject* Runtime::ForceSetObjectProperty(Isolate* isolate, return js_object->SetElement( index, *value, attr, kNonStrictMode, false, DEFINE_PROPERTY); } else { - return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr); + Handle result = JSObject::SetLocalPropertyIgnoreAttributes( + js_object, name, value, attr); + RETURN_IF_EMPTY_HANDLE(isolate, result); + return *result; } } @@ -5470,10 +5466,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrepareStepInIfStepping) { // Set a local property, even if it is READ_ONLY. If the property does not // exist, it will be added with attributes NONE. RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { - SealHandleScope shs(isolate); + HandleScope scope(isolate); RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); - CONVERT_ARG_CHECKED(JSObject, object, 0); - CONVERT_ARG_CHECKED(Name, name, 1); + CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); + CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); + CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); // Compute attributes. PropertyAttributes attributes = NONE; if (args.length() == 4) { @@ -5483,9 +5480,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); attributes = static_cast(unchecked_value); } - - return object-> - SetLocalPropertyIgnoreAttributes(name, args[2], attributes); + Handle result = JSObject::SetLocalPropertyIgnoreAttributes( + object, name, value, attributes); + RETURN_IF_EMPTY_HANDLE(isolate, result); + return *result; }