Handlify Runtime::SetObjectProperty
BUG= R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/62333002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17560 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
dccc06e132
commit
ef0c647c49
@ -3136,7 +3136,7 @@ bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value,
|
||||
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
|
||||
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
|
||||
EXCEPTION_PREAMBLE(isolate);
|
||||
i::Handle<i::Object> obj = i::SetProperty(
|
||||
i::Handle<i::Object> obj = i::Runtime::SetObjectProperty(
|
||||
isolate,
|
||||
self,
|
||||
key_obj,
|
||||
|
@ -160,20 +160,6 @@ Handle<String> FlattenGetString(Handle<String> string) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetProperty(Isolate* isolate,
|
||||
Handle<Object> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes,
|
||||
StrictModeFlag strict_mode) {
|
||||
CALL_HEAP_FUNCTION(
|
||||
isolate,
|
||||
Runtime::SetObjectProperty(
|
||||
isolate, object, key, value, attributes, strict_mode),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ForceSetProperty(Handle<JSObject> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
|
@ -228,13 +228,6 @@ void FlattenString(Handle<String> str);
|
||||
// string.
|
||||
Handle<String> FlattenGetString(Handle<String> str);
|
||||
|
||||
Handle<Object> SetProperty(Isolate* isolate,
|
||||
Handle<Object> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes,
|
||||
StrictModeFlag strict_mode);
|
||||
|
||||
Handle<Object> ForceSetProperty(Handle<JSObject> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
|
53
src/ic.cc
53
src/ic.cc
@ -1920,8 +1920,13 @@ MaybeObject* KeyedStoreIC::Store(Handle<Object> object,
|
||||
Handle<Object> value,
|
||||
ICMissMode miss_mode) {
|
||||
if (MigrateDeprecated(object)) {
|
||||
return Runtime::SetObjectPropertyOrFail(
|
||||
isolate(), object , key, value, NONE, strict_mode());
|
||||
Handle<Object> result = Runtime::SetObjectProperty(isolate(), object,
|
||||
key,
|
||||
value,
|
||||
NONE,
|
||||
strict_mode());
|
||||
RETURN_IF_EMPTY_HANDLE(isolate(), result);
|
||||
return *result;
|
||||
}
|
||||
|
||||
// Check for values that can be converted into an internalized string directly
|
||||
@ -1986,8 +1991,12 @@ MaybeObject* KeyedStoreIC::Store(Handle<Object> object,
|
||||
}
|
||||
|
||||
if (maybe_object) return maybe_object;
|
||||
return Runtime::SetObjectPropertyOrFail(
|
||||
isolate(), object , key, value, NONE, strict_mode());
|
||||
Handle<Object> result = Runtime::SetObjectProperty(isolate(), object, key,
|
||||
value,
|
||||
NONE,
|
||||
strict_mode());
|
||||
RETURN_IF_EMPTY_HANDLE(isolate(), result);
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
||||
@ -2218,12 +2227,12 @@ RUNTIME_FUNCTION(MaybeObject*, StoreIC_Slow) {
|
||||
Handle<Object> key = args.at<Object>(1);
|
||||
Handle<Object> value = args.at<Object>(2);
|
||||
StrictModeFlag strict_mode = ic.strict_mode();
|
||||
return Runtime::SetObjectProperty(isolate,
|
||||
object,
|
||||
key,
|
||||
value,
|
||||
NONE,
|
||||
strict_mode);
|
||||
Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
|
||||
value,
|
||||
NONE,
|
||||
strict_mode);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate, result);
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
||||
@ -2235,12 +2244,12 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) {
|
||||
Handle<Object> key = args.at<Object>(1);
|
||||
Handle<Object> value = args.at<Object>(2);
|
||||
StrictModeFlag strict_mode = ic.strict_mode();
|
||||
return Runtime::SetObjectProperty(isolate,
|
||||
object,
|
||||
key,
|
||||
value,
|
||||
NONE,
|
||||
strict_mode);
|
||||
Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
|
||||
value,
|
||||
NONE,
|
||||
strict_mode);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate, result);
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
||||
@ -2268,12 +2277,12 @@ RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss) {
|
||||
JSObject::TransitionElementsKind(Handle<JSObject>::cast(object),
|
||||
map->elements_kind());
|
||||
}
|
||||
return Runtime::SetObjectProperty(isolate,
|
||||
object,
|
||||
key,
|
||||
value,
|
||||
NONE,
|
||||
strict_mode);
|
||||
Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
|
||||
value,
|
||||
NONE,
|
||||
strict_mode);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate, result);
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
||||
|
186
src/runtime.cc
186
src/runtime.cc
@ -5122,49 +5122,36 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDataProperty) {
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Runtime::SetObjectPropertyOrFail(
|
||||
Isolate* isolate,
|
||||
Handle<Object> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attr,
|
||||
StrictModeFlag strict_mode) {
|
||||
CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate,
|
||||
SetObjectProperty(isolate, object, key, value, attr, strict_mode));
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
||||
Handle<Object> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attr,
|
||||
StrictModeFlag strict_mode) {
|
||||
Handle<Object> Runtime::SetObjectProperty(Isolate* isolate,
|
||||
Handle<Object> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attr,
|
||||
StrictModeFlag strict_mode) {
|
||||
SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY;
|
||||
HandleScope scope(isolate);
|
||||
|
||||
if (object->IsUndefined() || object->IsNull()) {
|
||||
Handle<Object> args[2] = { key, object };
|
||||
Handle<Object> error =
|
||||
isolate->factory()->NewTypeError("non_object_property_store",
|
||||
HandleVector(args, 2));
|
||||
return isolate->Throw(*error);
|
||||
isolate->Throw(*error);
|
||||
return Handle<Object>();
|
||||
}
|
||||
|
||||
if (object->IsJSProxy()) {
|
||||
bool has_pending_exception = false;
|
||||
Handle<Object> name_object = key->IsSymbol()
|
||||
? key : Execution::ToString(isolate, key, &has_pending_exception);
|
||||
if (has_pending_exception) return Failure::Exception();
|
||||
if (has_pending_exception) return Handle<Object>(); // exception
|
||||
Handle<Name> name = Handle<Name>::cast(name_object);
|
||||
Handle<Object> result = JSReceiver::SetProperty(
|
||||
Handle<JSProxy>::cast(object), name, value, attr, strict_mode);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate, result);
|
||||
return *result;
|
||||
return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value,
|
||||
attr,
|
||||
strict_mode);
|
||||
}
|
||||
|
||||
// If the object isn't a JavaScript object, we ignore the store.
|
||||
if (!object->IsJSObject()) return *value;
|
||||
if (!object->IsJSObject()) return value;
|
||||
|
||||
Handle<JSObject> js_object = Handle<JSObject>::cast(object);
|
||||
|
||||
@ -5179,7 +5166,7 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
||||
// string does nothing with the assignment then we can ignore such
|
||||
// assignments.
|
||||
if (js_object->IsStringObjectWithCharacterAt(index)) {
|
||||
return *value;
|
||||
return value;
|
||||
}
|
||||
|
||||
js_object->ValidateElements();
|
||||
@ -5188,15 +5175,16 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
||||
bool has_exception;
|
||||
Handle<Object> number =
|
||||
Execution::ToNumber(isolate, value, &has_exception);
|
||||
if (has_exception) return Failure::Exception();
|
||||
if (has_exception) return Handle<Object>(); // exception
|
||||
value = number;
|
||||
}
|
||||
}
|
||||
MaybeObject* result = js_object->SetElement(
|
||||
index, *value, attr, strict_mode, true, set_mode);
|
||||
Handle<Object> result = JSObject::SetElement(js_object, index, value, attr,
|
||||
strict_mode,
|
||||
true,
|
||||
set_mode);
|
||||
js_object->ValidateElements();
|
||||
if (result->IsFailure()) return result;
|
||||
return *value;
|
||||
return result.is_null() ? result : value;
|
||||
}
|
||||
|
||||
if (key->IsName()) {
|
||||
@ -5207,37 +5195,32 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
||||
bool has_exception;
|
||||
Handle<Object> number =
|
||||
Execution::ToNumber(isolate, value, &has_exception);
|
||||
if (has_exception) return Failure::Exception();
|
||||
if (has_exception) return Handle<Object>(); // exception
|
||||
value = number;
|
||||
}
|
||||
}
|
||||
MaybeObject* result = js_object->SetElement(
|
||||
index, *value, attr, strict_mode, true, set_mode);
|
||||
if (result->IsFailure()) return result;
|
||||
return JSObject::SetElement(js_object, index, value, attr, strict_mode,
|
||||
true,
|
||||
set_mode);
|
||||
} else {
|
||||
if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
|
||||
Handle<Object> result =
|
||||
JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate, result);
|
||||
return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
||||
}
|
||||
return *value;
|
||||
}
|
||||
|
||||
// Call-back into JavaScript to convert the key to a string.
|
||||
bool has_pending_exception = false;
|
||||
Handle<Object> converted =
|
||||
Execution::ToString(isolate, key, &has_pending_exception);
|
||||
if (has_pending_exception) return Failure::Exception();
|
||||
if (has_pending_exception) return Handle<Object>(); // exception
|
||||
Handle<String> name = Handle<String>::cast(converted);
|
||||
|
||||
if (name->AsArrayIndex(&index)) {
|
||||
return js_object->SetElement(
|
||||
index, *value, attr, strict_mode, true, set_mode);
|
||||
return JSObject::SetElement(js_object, index, value, attr, strict_mode,
|
||||
true,
|
||||
set_mode);
|
||||
} else {
|
||||
Handle<Object> result =
|
||||
JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate, result);
|
||||
return *result;
|
||||
return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5341,12 +5324,12 @@ MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate,
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) {
|
||||
SealHandleScope shs(isolate);
|
||||
HandleScope scope(isolate);
|
||||
RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
|
||||
|
||||
Handle<Object> object = args.at<Object>(0);
|
||||
Handle<Object> key = args.at<Object>(1);
|
||||
Handle<Object> value = args.at<Object>(2);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
|
||||
CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
|
||||
RUNTIME_ASSERT(
|
||||
(unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
|
||||
@ -5360,12 +5343,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) {
|
||||
strict_mode = strict_mode_flag;
|
||||
}
|
||||
|
||||
return Runtime::SetObjectProperty(isolate,
|
||||
object,
|
||||
key,
|
||||
value,
|
||||
attributes,
|
||||
strict_mode);
|
||||
Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
|
||||
value,
|
||||
attributes,
|
||||
strict_mode);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate, result);
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
||||
@ -5386,10 +5369,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) {
|
||||
SealHandleScope shs(isolate);
|
||||
RUNTIME_ASSERT(args.length() == 1);
|
||||
|
||||
Handle<Object> object = args.at<Object>(0);
|
||||
CONVERT_ARG_CHECKED(Object, object, 0);
|
||||
|
||||
if (object->IsJSFunction()) {
|
||||
JSFunction* func = JSFunction::cast(*object);
|
||||
JSFunction* func = JSFunction::cast(object);
|
||||
func->shared()->set_native(true);
|
||||
}
|
||||
return isolate->heap()->undefined_value();
|
||||
@ -11348,12 +11331,12 @@ static Handle<JSObject> MaterializeStackLocalsWithFrameInspector(
|
||||
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(
|
||||
isolate,
|
||||
SetProperty(isolate,
|
||||
target,
|
||||
Handle<String>(scope_info->ParameterName(i)),
|
||||
value,
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Runtime::SetObjectProperty(isolate,
|
||||
target,
|
||||
Handle<String>(scope_info->ParameterName(i)),
|
||||
value,
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Handle<JSObject>());
|
||||
}
|
||||
|
||||
@ -11364,12 +11347,13 @@ static Handle<JSObject> MaterializeStackLocalsWithFrameInspector(
|
||||
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(
|
||||
isolate,
|
||||
SetProperty(isolate,
|
||||
target,
|
||||
Handle<String>(scope_info->StackLocalName(i)),
|
||||
value,
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Runtime::SetObjectProperty(
|
||||
isolate,
|
||||
target,
|
||||
Handle<String>(scope_info->StackLocalName(i)),
|
||||
value,
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Handle<JSObject>());
|
||||
}
|
||||
|
||||
@ -11447,12 +11431,12 @@ static Handle<JSObject> MaterializeLocalContext(Isolate* isolate,
|
||||
Handle<String> key(String::cast(keys->get(i)));
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(
|
||||
isolate,
|
||||
SetProperty(isolate,
|
||||
target,
|
||||
key,
|
||||
GetProperty(isolate, ext, key),
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Runtime::SetObjectProperty(isolate,
|
||||
target,
|
||||
key,
|
||||
GetProperty(isolate, ext, key),
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Handle<JSObject>());
|
||||
}
|
||||
}
|
||||
@ -11552,12 +11536,9 @@ static bool SetLocalVariableValue(Isolate* isolate,
|
||||
if (JSReceiver::HasProperty(ext, variable_name)) {
|
||||
// We don't expect this to do anything except replacing
|
||||
// property value.
|
||||
SetProperty(isolate,
|
||||
ext,
|
||||
variable_name,
|
||||
new_value,
|
||||
NONE,
|
||||
kNonStrictMode);
|
||||
Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
|
||||
NONE,
|
||||
kNonStrictMode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -11603,12 +11584,10 @@ static Handle<JSObject> MaterializeClosure(Isolate* isolate,
|
||||
Handle<String> key(String::cast(keys->get(i)));
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(
|
||||
isolate,
|
||||
SetProperty(isolate,
|
||||
closure_scope,
|
||||
key,
|
||||
GetProperty(isolate, ext, key),
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Runtime::SetObjectProperty(isolate, closure_scope, key,
|
||||
GetProperty(isolate, ext, key),
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Handle<JSObject>());
|
||||
}
|
||||
}
|
||||
@ -11639,12 +11618,9 @@ static bool SetClosureVariableValue(Isolate* isolate,
|
||||
Handle<JSObject> ext(JSObject::cast(context->extension()));
|
||||
if (JSReceiver::HasProperty(ext, variable_name)) {
|
||||
// We don't expect this to do anything except replacing property value.
|
||||
SetProperty(isolate,
|
||||
ext,
|
||||
variable_name,
|
||||
new_value,
|
||||
NONE,
|
||||
kNonStrictMode);
|
||||
Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
|
||||
NONE,
|
||||
kNonStrictMode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -11665,12 +11641,9 @@ static Handle<JSObject> MaterializeCatchScope(Isolate* isolate,
|
||||
isolate->factory()->NewJSObject(isolate->object_function());
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(
|
||||
isolate,
|
||||
SetProperty(isolate,
|
||||
catch_scope,
|
||||
name,
|
||||
thrown_object,
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object,
|
||||
NONE,
|
||||
kNonStrictMode),
|
||||
Handle<JSObject>());
|
||||
return catch_scope;
|
||||
}
|
||||
@ -12688,12 +12661,11 @@ static Handle<JSObject> MaterializeArgumentsObject(
|
||||
// FunctionGetArguments can't throw an exception.
|
||||
Handle<JSObject> arguments = Handle<JSObject>::cast(
|
||||
Accessors::FunctionGetArguments(function));
|
||||
SetProperty(isolate,
|
||||
target,
|
||||
isolate->factory()->arguments_string(),
|
||||
arguments,
|
||||
::NONE,
|
||||
kNonStrictMode);
|
||||
Runtime::SetObjectProperty(isolate, target,
|
||||
isolate->factory()->arguments_string(),
|
||||
arguments,
|
||||
::NONE,
|
||||
kNonStrictMode);
|
||||
return target;
|
||||
}
|
||||
|
||||
|
@ -776,15 +776,7 @@ class Runtime : public AllStatic {
|
||||
Handle<Object> object,
|
||||
uint32_t index);
|
||||
|
||||
MUST_USE_RESULT static MaybeObject* SetObjectProperty(
|
||||
Isolate* isolate,
|
||||
Handle<Object> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attr,
|
||||
StrictModeFlag strict_mode);
|
||||
|
||||
MUST_USE_RESULT static MaybeObject* SetObjectPropertyOrFail(
|
||||
static Handle<Object> SetObjectProperty(
|
||||
Isolate* isolate,
|
||||
Handle<Object> object,
|
||||
Handle<Object> key,
|
||||
|
@ -374,15 +374,14 @@ bool ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info,
|
||||
int end = start + local_count;
|
||||
for (int i = start; i < end; ++i) {
|
||||
int context_index = Context::MIN_CONTEXT_SLOTS + i - start;
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(
|
||||
Handle<Object> result = Runtime::SetObjectProperty(
|
||||
isolate,
|
||||
SetProperty(isolate,
|
||||
scope_object,
|
||||
Handle<String>(String::cast(scope_info->get(i))),
|
||||
Handle<Object>(context->get(context_index), isolate),
|
||||
::NONE,
|
||||
kNonStrictMode),
|
||||
false);
|
||||
scope_object,
|
||||
Handle<String>(String::cast(scope_info->get(i))),
|
||||
Handle<Object>(context->get(context_index), isolate),
|
||||
::NONE,
|
||||
kNonStrictMode);
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -92,7 +92,8 @@ static void SetGlobalProperty(const char* name, Object* value) {
|
||||
Handle<String> internalized_name =
|
||||
isolate->factory()->InternalizeUtf8String(name);
|
||||
Handle<JSObject> global(isolate->context()->global_object());
|
||||
SetProperty(isolate, global, internalized_name, object, NONE, kNonStrictMode);
|
||||
Runtime::SetObjectProperty(isolate, global, internalized_name, object, NONE,
|
||||
kNonStrictMode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -169,10 +169,10 @@ class DebugLocalContext {
|
||||
v8::Utils::OpenHandle(*context_->Global())));
|
||||
Handle<v8::internal::String> debug_string =
|
||||
factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
|
||||
SetProperty(isolate, global, debug_string,
|
||||
Handle<Object>(debug->debug_context()->global_proxy(), isolate),
|
||||
DONT_ENUM,
|
||||
::v8::internal::kNonStrictMode);
|
||||
v8::internal::Runtime::SetObjectProperty(isolate, global, debug_string,
|
||||
Handle<Object>(debug->debug_context()->global_proxy(), isolate),
|
||||
DONT_ENUM,
|
||||
::v8::internal::kNonStrictMode);
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user