Commit fa3e6c08 authored by verwaest's avatar verwaest Committed by Commit bot

Introduce DefineOwnPropertyIgnoreAttributes and make it call SetPropertyWithInterceptor.

Otherwise using Object.defineProperty with window.localStorage will not actually store the value into the database but on the object itself.

BUG=v8:4137
LOG=n

Review URL: https://codereview.chromium.org/1180073002

Cr-Commit-Position: refs/heads/master@{#29002}
parent 6a109318
...@@ -3638,7 +3638,8 @@ static i::MaybeHandle<i::Object> DefineObjectProperty( ...@@ -3638,7 +3638,8 @@ static i::MaybeHandle<i::Object> DefineObjectProperty(
name = i::Handle<i::String>::cast(converted); name = i::Handle<i::String>::cast(converted);
} }
return i::JSObject::DefinePropertyOrElement(js_object, name, value, attrs); return i::JSObject::DefinePropertyOrElementIgnoreAttributes(js_object, name,
value, attrs);
} }
......
...@@ -434,7 +434,8 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() { ...@@ -434,7 +434,8 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
// Commit the intermediate state to the object and stop transitioning. // Commit the intermediate state to the object and stop transitioning.
CommitStateToJsonObject(json_object, map, &properties); CommitStateToJsonObject(json_object, map, &properties);
JSObject::DefinePropertyOrElement(json_object, key, value).Check(); JSObject::DefinePropertyOrElementIgnoreAttributes(json_object, key, value)
.Check();
} while (transitioning && MatchSkipWhiteSpace(',')); } while (transitioning && MatchSkipWhiteSpace(','));
// If we transitioned until the very end, transition the map now. // If we transitioned until the very end, transition the map now.
...@@ -470,7 +471,8 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() { ...@@ -470,7 +471,8 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
value = ParseJsonValue(); value = ParseJsonValue();
if (value.is_null()) return ReportUnexpectedCharacter(); if (value.is_null()) return ReportUnexpectedCharacter();
JSObject::DefinePropertyOrElement(json_object, key, value).Check(); JSObject::DefinePropertyOrElementIgnoreAttributes(json_object, key,
value).Check();
} }
} }
......
...@@ -1197,22 +1197,6 @@ MaybeHandle<Object> Object::GetProperty(Isolate* isolate, ...@@ -1197,22 +1197,6 @@ MaybeHandle<Object> Object::GetProperty(Isolate* isolate,
} }
MaybeHandle<Object> JSObject::DefinePropertyOrElement(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes, ExecutableAccessorInfoHandling handling) {
uint32_t index;
if (name->AsArrayIndex(&index)) {
return SetOwnElementIgnoreAttributes(object, index, value, attributes,
handling);
}
// TODO(verwaest): Is this necessary?
if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
return SetOwnPropertyIgnoreAttributes(object, name, value, attributes,
handling);
}
#define FIELD_ADDR(p, offset) \ #define FIELD_ADDR(p, offset) \
(reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag)
......
This diff is collapsed.
...@@ -1842,11 +1842,8 @@ class JSObject: public JSReceiver { ...@@ -1842,11 +1842,8 @@ class JSObject: public JSReceiver {
// grant an exemption to ExecutableAccessor callbacks in some cases. // grant an exemption to ExecutableAccessor callbacks in some cases.
enum ExecutableAccessorInfoHandling { DEFAULT_HANDLING, DONT_FORCE_FIELD }; enum ExecutableAccessorInfoHandling { DEFAULT_HANDLING, DONT_FORCE_FIELD };
// Calls SetOwn[Property|Element]IgnoreAttributes depending on whether name is MUST_USE_RESULT static MaybeHandle<Object> DefineOwnPropertyIgnoreAttributes(
// convertible to an index. LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
MUST_USE_RESULT static inline MaybeHandle<Object> DefinePropertyOrElement(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes = NONE,
ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes( MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes(
...@@ -1859,8 +1856,12 @@ class JSObject: public JSReceiver { ...@@ -1859,8 +1856,12 @@ class JSObject: public JSReceiver {
PropertyAttributes attributes, PropertyAttributes attributes,
ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
MUST_USE_RESULT static MaybeHandle<Object> ReconfigureAsDataProperty( // Equivalent to one of the above depending on whether |name| can be converted
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes, // to an array index.
MUST_USE_RESULT static MaybeHandle<Object>
DefinePropertyOrElementIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes = NONE,
ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
static void AddProperty(Handle<JSObject> object, Handle<Name> name, static void AddProperty(Handle<JSObject> object, Handle<Name> name,
...@@ -2315,7 +2316,7 @@ class JSObject: public JSReceiver { ...@@ -2315,7 +2316,7 @@ class JSObject: public JSReceiver {
LookupIterator* it); LookupIterator* it);
MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck( MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode); LookupIterator* it, Handle<Object> value);
// Add a property to a slow-case object. // Add a property to a slow-case object.
static void AddSlowProperty(Handle<JSObject> object, static void AddSlowProperty(Handle<JSObject> object,
......
...@@ -200,8 +200,9 @@ RUNTIME_FUNCTION(Runtime_DefineClassMethod) { ...@@ -200,8 +200,9 @@ RUNTIME_FUNCTION(Runtime_DefineClassMethod) {
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2); CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2);
RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::DefinePropertyOrElement( RETURN_FAILURE_ON_EXCEPTION(isolate,
object, name, function, DONT_ENUM)); JSObject::DefinePropertyOrElementIgnoreAttributes(
object, name, function, DONT_ENUM));
return isolate->heap()->undefined_value(); return isolate->heap()->undefined_value();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment