diff --git a/src/factory.h b/src/factory.h index fc48b3201f..1bdf474337 100644 --- a/src/factory.h +++ b/src/factory.h @@ -639,6 +639,24 @@ class IdempotentPointerToHandleCodeTrampoline { : reinterpret_cast(Failure::RetryAfterGC()); } + template + MUST_USE_RESULT MaybeObject* CallWithReturnValue( + R (*function)(P1, P2, P3, P4, P5, P6, P7), + P1 p1, + P2 p2, + P3 p3, + P4 p4, + P5 p5, + P6 p6, + P7 p7) { + int collections = isolate_->heap()->gc_count(); + Handle result = (*function)(p1, p2, p3, p4, p5, p6, p7); + return (collections == isolate_->heap()->gc_count()) + ? *result + : reinterpret_cast(Failure::RetryAfterGC()); + } + private: Isolate* isolate_; }; diff --git a/src/objects.cc b/src/objects.cc index 647687158f..b984a40507 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -4029,6 +4029,29 @@ MaybeObject* JSObject::SetPropertyForResult(LookupResult* lookup, } +MaybeObject* JSObject::SetLocalPropertyIgnoreAttributesTrampoline( + Name* key, + Object* value, + PropertyAttributes attributes, + ValueType value_type, + StoreMode mode, + ExtensibilityCheck extensibility_check) { + // TODO(mstarzinger): The trampoline is a giant hack, don't use it anywhere + // else or handlification people will start hating you for all eternity. + HandleScope scope(GetIsolate()); + IdempotentPointerToHandleCodeTrampoline trampoline(GetIsolate()); + return trampoline.CallWithReturnValue( + &JSObject::SetLocalPropertyIgnoreAttributes, + Handle(this), + Handle(key), + Handle(value, GetIsolate()), + attributes, + value_type, + mode, + extensibility_check); +} + + // Set a real local property, even if it is READ_ONLY. If the property is not // present, add it with attributes NONE. This code is an exact clone of // SetProperty, with the check for IsReadOnly and the check for a @@ -4044,11 +4067,12 @@ Handle JSObject::SetLocalPropertyIgnoreAttributes( Handle value, PropertyAttributes attributes, ValueType value_type, - StoreMode mode) { + StoreMode mode, + ExtensibilityCheck extensibility_check) { CALL_HEAP_FUNCTION( object->GetIsolate(), object->SetLocalPropertyIgnoreAttributes( - *key, *value, attributes, value_type, mode), + *key, *value, attributes, value_type, mode, extensibility_check), Object); } @@ -4951,13 +4975,13 @@ MaybeObject* JSObject::GetHiddenPropertiesHashTable( ASSERT_EQ(hashtable, new_table); } - MaybeObject* store_result = - SetLocalPropertyIgnoreAttributes(GetHeap()->hidden_string(), - hashtable, - DONT_ENUM, - OPTIMAL_REPRESENTATION, - ALLOW_AS_CONSTANT, - OMIT_EXTENSIBILITY_CHECK); + MaybeObject* store_result = SetLocalPropertyIgnoreAttributesTrampoline( + GetHeap()->hidden_string(), + hashtable, + DONT_ENUM, + OPTIMAL_REPRESENTATION, + ALLOW_AS_CONSTANT, + OMIT_EXTENSIBILITY_CHECK); if (store_result->IsFailure()) return store_result; return hashtable; } @@ -4984,13 +5008,13 @@ MaybeObject* JSObject::SetHiddenPropertiesHashTable(Object* value) { } } } - MaybeObject* store_result = - SetLocalPropertyIgnoreAttributes(GetHeap()->hidden_string(), - value, - DONT_ENUM, - OPTIMAL_REPRESENTATION, - ALLOW_AS_CONSTANT, - OMIT_EXTENSIBILITY_CHECK); + MaybeObject* store_result = SetLocalPropertyIgnoreAttributesTrampoline( + GetHeap()->hidden_string(), + value, + DONT_ENUM, + OPTIMAL_REPRESENTATION, + ALLOW_AS_CONSTANT, + OMIT_EXTENSIBILITY_CHECK); if (store_result->IsFailure()) return store_result; return this; } diff --git a/src/objects.h b/src/objects.h index ccfc591001..56ce497f83 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2163,7 +2163,8 @@ class JSObject: public JSReceiver { Handle value, PropertyAttributes attributes, ValueType value_type = OPTIMAL_REPRESENTATION, - StoreMode mode = ALLOW_AS_CONSTANT); + StoreMode mode = ALLOW_AS_CONSTANT, + ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); static inline Handle ExpectedTransitionKey(Handle map); static inline Handle ExpectedTransitionTarget(Handle map); @@ -2194,6 +2195,13 @@ class JSObject: public JSReceiver { 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, + PropertyAttributes attributes, + ValueType value_type = OPTIMAL_REPRESENTATION, + StoreMode mode = ALLOW_AS_CONSTANT, + ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); // Retrieve a value in a normalized object given a lookup result. // Handles the special representation of JS global objects.