| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index a698445792ecf2a173adb830f8976d7919f0145a..3787e0c77ca88afe9b6199993ffcb70424b87075 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -506,32 +506,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) {
|
| }
|
|
|
|
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) {
|
| - HandleScope scope(isolate);
|
| - ASSERT(args.length() == 4);
|
| - CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
|
| - CONVERT_SMI_ARG_CHECKED(literals_index, 1);
|
| - CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
|
| - CONVERT_SMI_ARG_CHECKED(flags, 3);
|
| - bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
|
| - bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
|
| -
|
| - // Check if boilerplate exists. If not, create it first.
|
| - Handle<Object> boilerplate(literals->get(literals_index), isolate);
|
| - if (*boilerplate == isolate->heap()->undefined_value()) {
|
| - boilerplate = CreateObjectLiteralBoilerplate(isolate,
|
| - literals,
|
| - constant_properties,
|
| - should_have_fast_elements,
|
| - has_function_literal);
|
| - RETURN_IF_EMPTY_HANDLE(isolate, boilerplate);
|
| - // Update the functions literal and return the boilerplate.
|
| - literals->set(literals_index, *boilerplate);
|
| - }
|
| - return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
|
| -}
|
| -
|
| -
|
| static Handle<AllocationSite> GetLiteralAllocationSite(
|
| Isolate* isolate,
|
| Handle<FixedArray> literals,
|
| @@ -2169,7 +2143,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) {
|
| // Declare the property by setting it to the initial value if provided,
|
| // or undefined, and use the correct mode (e.g. READ_ONLY attribute for
|
| // constant declarations).
|
| - ASSERT(!object->HasLocalProperty(*name));
|
| + ASSERT(!JSReceiver::HasLocalProperty(object, name));
|
| Handle<Object> value(isolate->heap()->undefined_value(), isolate);
|
| if (*initial_value != NULL) value = initial_value;
|
| // Declaring a const context slot is a conflicting declaration if
|
| @@ -2201,7 +2175,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) {
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) {
|
| - SealHandleScope shs(isolate);
|
| + HandleScope scope(isolate);
|
| // args[0] == name
|
| // args[1] == language_mode
|
| // args[2] == value (optional)
|
| @@ -2212,7 +2186,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) {
|
| bool assign = args.length() == 3;
|
|
|
| CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
|
| - GlobalObject* global = isolate->context()->global_object();
|
| RUNTIME_ASSERT(args[1]->IsSmi());
|
| CONVERT_LANGUAGE_MODE_ARG(language_mode, 1);
|
| StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE)
|
| @@ -2229,28 +2202,33 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) {
|
| // to assign to the property.
|
| // Note that objects can have hidden prototypes, so we need to traverse
|
| // the whole chain of hidden prototypes to do a 'local' lookup.
|
| - Object* object = global;
|
| LookupResult lookup(isolate);
|
| - JSObject::cast(object)->LocalLookup(*name, &lookup, true);
|
| + isolate->context()->global_object()->LocalLookup(*name, &lookup, true);
|
| if (lookup.IsInterceptor()) {
|
| - HandleScope handle_scope(isolate);
|
| PropertyAttributes intercepted =
|
| lookup.holder()->GetPropertyAttribute(*name);
|
| if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
|
| // Found an interceptor that's not read only.
|
| if (assign) {
|
| - return lookup.holder()->SetProperty(
|
| - &lookup, *name, args[2], attributes, strict_mode_flag);
|
| + CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
|
| + Handle<Object> result = JSObject::SetPropertyForResult(
|
| + handle(lookup.holder()), &lookup, name, value, attributes,
|
| + strict_mode_flag);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| + return *result;
|
| } else {
|
| return isolate->heap()->undefined_value();
|
| }
|
| }
|
| }
|
|
|
| - // Reload global in case the loop above performed a GC.
|
| - global = isolate->context()->global_object();
|
| if (assign) {
|
| - return global->SetProperty(*name, args[2], attributes, strict_mode_flag);
|
| + CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
|
| + Handle<GlobalObject> global(isolate->context()->global_object());
|
| + Handle<Object> result = JSReceiver::SetProperty(
|
| + global, name, value, attributes, strict_mode_flag);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| + return *result;
|
| }
|
| return isolate->heap()->undefined_value();
|
| }
|
| @@ -3095,10 +3073,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowGeneratorStateError) {
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectFreeze) {
|
| - SealHandleScope shs(isolate);
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| - CONVERT_ARG_CHECKED(JSObject, object, 0);
|
| - return object->Freeze(isolate);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
|
| + Handle<Object> result = JSObject::Freeze(object);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| + return *result;
|
| }
|
|
|
|
|
| @@ -4783,7 +4763,7 @@ MaybeObject* Runtime::HasObjectProperty(Isolate* isolate,
|
| // Check if the given key is an array index.
|
| uint32_t index;
|
| if (key->ToArrayIndex(&index)) {
|
| - return isolate->heap()->ToBoolean(object->HasElement(index));
|
| + return isolate->heap()->ToBoolean(JSReceiver::HasElement(object, index));
|
| }
|
|
|
| // Convert the key to a name - possibly by calling back into JavaScript.
|
| @@ -4798,7 +4778,7 @@ MaybeObject* Runtime::HasObjectProperty(Isolate* isolate,
|
| name = Handle<Name>::cast(converted);
|
| }
|
|
|
| - return isolate->heap()->ToBoolean(object->HasProperty(*name));
|
| + return isolate->heap()->ToBoolean(JSReceiver::HasProperty(object, name));
|
| }
|
|
|
| MaybeObject* Runtime::GetObjectPropertyOrFail(
|
| @@ -5033,11 +5013,15 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
|
| // TODO(mstarzinger): So far this only works if property attributes don't
|
| // change, this should be fixed once we cleanup the underlying code.
|
| if (callback->IsForeign() && result.GetAttributes() == attr) {
|
| - return js_object->SetPropertyWithCallback(callback,
|
| - *name,
|
| - *obj_value,
|
| - result.holder(),
|
| - kStrictMode);
|
| + Handle<Object> result_object =
|
| + JSObject::SetPropertyWithCallback(js_object,
|
| + handle(callback, isolate),
|
| + name,
|
| + obj_value,
|
| + handle(result.holder()),
|
| + kStrictMode);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result_object);
|
| + return *result_object;
|
| }
|
| }
|
|
|
| @@ -5133,11 +5117,14 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
|
|
| if (object->IsJSProxy()) {
|
| bool has_pending_exception = false;
|
| - Handle<Object> name = key->IsSymbol()
|
| + Handle<Object> name_object = key->IsSymbol()
|
| ? key : Execution::ToString(isolate, key, &has_pending_exception);
|
| if (has_pending_exception) return Failure::Exception();
|
| - return JSProxy::cast(*object)->SetProperty(
|
| - Name::cast(*name), *value, attr, strict_mode);
|
| + 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;
|
| }
|
|
|
| // If the object isn't a JavaScript object, we ignore the store.
|
| @@ -5177,7 +5164,6 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
| }
|
|
|
| if (key->IsName()) {
|
| - MaybeObject* result;
|
| Handle<Name> name = Handle<Name>::cast(key);
|
| if (name->AsArrayIndex(&index)) {
|
| if (js_object->HasExternalArrayElements()) {
|
| @@ -5189,13 +5175,15 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
| value = number;
|
| }
|
| }
|
| - result = js_object->SetElement(
|
| + MaybeObject* result = js_object->SetElement(
|
| index, *value, attr, strict_mode, true, set_mode);
|
| + if (result->IsFailure()) return result;
|
| } else {
|
| if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
|
| - result = js_object->SetProperty(*name, *value, attr, strict_mode);
|
| + Handle<Object> result =
|
| + JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| }
|
| - if (result->IsFailure()) return result;
|
| return *value;
|
| }
|
|
|
| @@ -5210,7 +5198,10 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
| return js_object->SetElement(
|
| index, *value, attr, strict_mode, true, set_mode);
|
| } else {
|
| - return js_object->SetProperty(*name, *value, attr, strict_mode);
|
| + Handle<Object> result =
|
| + JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| + return *result;
|
| }
|
| }
|
|
|
| @@ -5509,7 +5500,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) {
|
| static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate,
|
| Handle<JSObject> object,
|
| Handle<Name> key) {
|
| - if (object->HasLocalProperty(*key)) return isolate->heap()->true_value();
|
| + if (JSReceiver::HasLocalProperty(object, key)) {
|
| + return isolate->heap()->true_value();
|
| + }
|
| // Handle hidden prototypes. If there's a hidden prototype above this thing
|
| // then we have to check it for properties, because they are supposed to
|
| // look like they are on this object.
|
| @@ -5569,12 +5562,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) {
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) {
|
| - SealHandleScope shs(isolate);
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| - CONVERT_ARG_CHECKED(JSReceiver, receiver, 0);
|
| - CONVERT_ARG_CHECKED(Name, key, 1);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
|
| + CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
|
|
|
| - bool result = receiver->HasProperty(key);
|
| + bool result = JSReceiver::HasProperty(receiver, key);
|
| RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (isolate->has_pending_exception()) return Failure::Exception();
|
| return isolate->heap()->ToBoolean(result);
|
| @@ -5582,12 +5575,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) {
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) {
|
| - SealHandleScope shs(isolate);
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| - CONVERT_ARG_CHECKED(JSReceiver, receiver, 0);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
|
| CONVERT_SMI_ARG_CHECKED(index, 1);
|
|
|
| - bool result = receiver->HasElement(index);
|
| + bool result = JSReceiver::HasElement(receiver, index);
|
| RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (isolate->has_pending_exception()) return Failure::Exception();
|
| return isolate->heap()->ToBoolean(result);
|
| @@ -8506,8 +8499,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) {
|
| if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) {
|
| // Start patching from the currently patched loop nesting level.
|
| int current_level = unoptimized->allow_osr_at_loop_nesting_level();
|
| - ASSERT(Deoptimizer::VerifyInterruptCode(
|
| - isolate, unoptimized, current_level));
|
| + ASSERT(BackEdgeTable::Verify(isolate, unoptimized, current_level));
|
| for (int i = current_level + 1; i <= Code::kMaxLoopNestingMarker; i++) {
|
| unoptimized->set_allow_osr_at_loop_nesting_level(i);
|
| isolate->runtime_profiler()->AttemptOnStackReplacement(*function);
|
| @@ -8660,8 +8652,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
|
| result = JSFunction::CompileOsr(function, ast_id, CLEAR_EXCEPTION);
|
| }
|
|
|
| - // Revert the patched interrupt now, regardless of whether OSR succeeds.
|
| - Deoptimizer::RevertInterruptCode(isolate, *unoptimized);
|
| + // Revert the patched back edge table, regardless of whether OSR succeeds.
|
| + BackEdgeTable::Revert(isolate, *unoptimized);
|
|
|
| // Check whether we ended up with usable optimized code.
|
| if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) {
|
| @@ -9198,7 +9190,7 @@ static ObjectPair LoadContextSlotHelper(Arguments args,
|
| // property from it.
|
| if (!holder.is_null()) {
|
| Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder);
|
| - ASSERT(object->IsJSProxy() || object->HasProperty(*name));
|
| + ASSERT(object->IsJSProxy() || JSReceiver::HasProperty(object, name));
|
| // GetProperty below can cause GC.
|
| Handle<Object> receiver_handle(
|
| object->IsGlobalObject()
|
| @@ -10179,7 +10171,7 @@ static bool IterateElements(Isolate* isolate,
|
| Handle<Object> element_value(elements->get(j), isolate);
|
| if (!element_value->IsTheHole()) {
|
| visitor->visit(j, element_value);
|
| - } else if (receiver->HasElement(j)) {
|
| + } else if (JSReceiver::HasElement(receiver, j)) {
|
| // Call GetElement on receiver, not its prototype, or getters won't
|
| // have the correct receiver.
|
| element_value = Object::GetElement(isolate, receiver, j);
|
| @@ -10204,7 +10196,7 @@ static bool IterateElements(Isolate* isolate,
|
| Handle<Object> element_value =
|
| isolate->factory()->NewNumber(double_value);
|
| visitor->visit(j, element_value);
|
| - } else if (receiver->HasElement(j)) {
|
| + } else if (JSReceiver::HasElement(receiver, j)) {
|
| // Call GetElement on receiver, not its prototype, or getters won't
|
| // have the correct receiver.
|
| Handle<Object> element_value =
|
| @@ -11520,7 +11512,7 @@ static bool SetLocalVariableValue(Isolate* isolate,
|
| !function_context->IsNativeContext()) {
|
| Handle<JSObject> ext(JSObject::cast(function_context->extension()));
|
|
|
| - if (ext->HasProperty(*variable_name)) {
|
| + if (JSReceiver::HasProperty(ext, variable_name)) {
|
| // We don't expect this to do anything except replacing
|
| // property value.
|
| SetProperty(isolate,
|
| @@ -11608,7 +11600,7 @@ static bool SetClosureVariableValue(Isolate* isolate,
|
| // be variables introduced by eval.
|
| if (context->has_extension()) {
|
| Handle<JSObject> ext(JSObject::cast(context->extension()));
|
| - if (ext->HasProperty(*variable_name)) {
|
| + if (JSReceiver::HasProperty(ext, variable_name)) {
|
| // We don't expect this to do anything except replacing property value.
|
| SetProperty(isolate,
|
| ext,
|
| @@ -12651,7 +12643,8 @@ static Handle<JSObject> MaterializeArgumentsObject(
|
| // Do not materialize the arguments object for eval or top-level code.
|
| // Skip if "arguments" is already taken.
|
| if (!function->shared()->is_function() ||
|
| - target->HasLocalProperty(isolate->heap()->arguments_string())) {
|
| + JSReceiver::HasLocalProperty(target,
|
| + isolate->factory()->arguments_string())) {
|
| return target;
|
| }
|
|
|
|
|