| Index: src/runtime/runtime-scopes.cc
|
| diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc
|
| index de0d66a74e4e1287798bf99f9707919850f9d8ce..11fdc0f4791a2d8421f81b8c378905124a14cb4a 100644
|
| --- a/src/runtime/runtime-scopes.cc
|
| +++ b/src/runtime/runtime-scopes.cc
|
| @@ -237,10 +237,7 @@ Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name,
|
| // Check for a conflict with a lexically scoped variable
|
| context_arg->Lookup(name, LEXICAL_TEST, &index, &attributes,
|
| &binding_flags);
|
| - if (attributes != ABSENT &&
|
| - (binding_flags == MUTABLE_CHECK_INITIALIZED ||
|
| - binding_flags == IMMUTABLE_CHECK_INITIALIZED ||
|
| - binding_flags == IMMUTABLE_CHECK_INITIALIZED_HARMONY)) {
|
| + if (attributes != ABSENT && binding_flags == BINDING_CHECK_INITIALIZED) {
|
| return ThrowRedeclarationError(isolate, name);
|
| }
|
| attr = static_cast<PropertyAttributes>(attr & ~EVAL_DECLARED);
|
| @@ -339,86 +336,6 @@ RUNTIME_FUNCTION(Runtime_DeclareLookupSlot) {
|
| }
|
|
|
|
|
| -RUNTIME_FUNCTION(Runtime_InitializeLegacyConstLookupSlot) {
|
| - HandleScope scope(isolate);
|
| - DCHECK(args.length() == 3);
|
| -
|
| - CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
|
| - DCHECK(!value->IsTheHole());
|
| - // Initializations are always done in a function or native context.
|
| - CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1);
|
| - Handle<Context> context(context_arg->declaration_context());
|
| - CONVERT_ARG_HANDLE_CHECKED(String, name, 2);
|
| -
|
| - int index;
|
| - PropertyAttributes attributes;
|
| - ContextLookupFlags flags = DONT_FOLLOW_CHAINS;
|
| - BindingFlags binding_flags;
|
| - Handle<Object> holder =
|
| - context->Lookup(name, flags, &index, &attributes, &binding_flags);
|
| - if (holder.is_null()) {
|
| - // In case of JSProxy, an exception might have been thrown.
|
| - if (isolate->has_pending_exception()) return isolate->heap()->exception();
|
| - }
|
| -
|
| - if (index != Context::kNotFound) {
|
| - DCHECK(holder->IsContext());
|
| - // Property was found in a context. Perform the assignment if the constant
|
| - // was uninitialized.
|
| - Handle<Context> context = Handle<Context>::cast(holder);
|
| - DCHECK((attributes & READ_ONLY) != 0);
|
| - if (context->get(index)->IsTheHole()) context->set(index, *value);
|
| - return *value;
|
| - }
|
| -
|
| - PropertyAttributes attr =
|
| - static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
|
| -
|
| - // Strict mode handling not needed (legacy const is disallowed in strict
|
| - // mode).
|
| -
|
| - // The declared const was configurable, and may have been deleted in the
|
| - // meanwhile. If so, re-introduce the variable in the context extension.
|
| - if (attributes == ABSENT) {
|
| - Handle<Context> declaration_context(context_arg->declaration_context());
|
| - if (declaration_context->IsScriptContext()) {
|
| - holder = handle(declaration_context->global_object(), isolate);
|
| - } else {
|
| - holder = handle(declaration_context->extension_object(), isolate);
|
| - DCHECK(!holder.is_null());
|
| - }
|
| - CHECK(holder->IsJSObject());
|
| - } else {
|
| - // For JSContextExtensionObjects, the initializer can be run multiple times
|
| - // if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the
|
| - // first assignment should go through. For JSGlobalObjects, additionally any
|
| - // code can run in between that modifies the declared property.
|
| - DCHECK(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject());
|
| -
|
| - LookupIterator it(holder, name, Handle<JSReceiver>::cast(holder),
|
| - LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
|
| - Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
|
| - if (!maybe.IsJust()) return isolate->heap()->exception();
|
| - PropertyAttributes old_attributes = maybe.FromJust();
|
| -
|
| - // Ignore if we can't reconfigure the value.
|
| - if ((old_attributes & DONT_DELETE) != 0) {
|
| - if ((old_attributes & READ_ONLY) != 0 ||
|
| - it.state() == LookupIterator::ACCESSOR) {
|
| - return *value;
|
| - }
|
| - attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY);
|
| - }
|
| - }
|
| -
|
| - RETURN_FAILURE_ON_EXCEPTION(
|
| - isolate, JSObject::SetOwnPropertyIgnoreAttributes(
|
| - Handle<JSObject>::cast(holder), name, value, attr));
|
| -
|
| - return *value;
|
| -}
|
| -
|
| -
|
| namespace {
|
|
|
| // Find the arguments of the JavaScript function invocation that called
|
| @@ -875,8 +792,7 @@ RUNTIME_FUNCTION(Runtime_DeclareModules) {
|
| case VAR:
|
| case LET:
|
| case CONST:
|
| - case CONST_LEGACY:
|
| - case IMPORT: {
|
| + case CONST_LEGACY: {
|
| PropertyAttributes attr =
|
| IsImmutableVariableMode(mode) ? FROZEN : SEALED;
|
| Handle<AccessorInfo> info =
|
| @@ -961,23 +877,14 @@ MaybeHandle<Object> LoadLookupSlot(Handle<String> name,
|
| Handle<Object> value = handle(Context::cast(*holder)->get(index), isolate);
|
| // Check for uninitialized bindings.
|
| switch (flags) {
|
| - case MUTABLE_CHECK_INITIALIZED:
|
| - case IMMUTABLE_CHECK_INITIALIZED_HARMONY:
|
| + case BINDING_CHECK_INITIALIZED:
|
| if (value->IsTheHole()) {
|
| THROW_NEW_ERROR(isolate,
|
| NewReferenceError(MessageTemplate::kNotDefined, name),
|
| Object);
|
| }
|
| // FALLTHROUGH
|
| - case IMMUTABLE_CHECK_INITIALIZED:
|
| - if (value->IsTheHole()) {
|
| - DCHECK(attributes & READ_ONLY);
|
| - value = isolate->factory()->undefined_value();
|
| - }
|
| - // FALLTHROUGH
|
| - case MUTABLE_IS_INITIALIZED:
|
| - case IMMUTABLE_IS_INITIALIZED:
|
| - case IMMUTABLE_IS_INITIALIZED_HARMONY:
|
| + case BINDING_IS_INITIALIZED:
|
| DCHECK(!value->IsTheHole());
|
| if (receiver_return) *receiver_return = receiver;
|
| return value;
|
| @@ -1075,8 +982,7 @@ MaybeHandle<Object> StoreLookupSlot(Handle<String> name, Handle<Object> value,
|
|
|
| // The property was found in a context slot.
|
| if (index != Context::kNotFound) {
|
| - if ((flags == MUTABLE_CHECK_INITIALIZED ||
|
| - flags == IMMUTABLE_CHECK_INITIALIZED_HARMONY) &&
|
| + if (flags == BINDING_CHECK_INITIALIZED &&
|
| Handle<Context>::cast(holder)->is_the_hole(index)) {
|
| THROW_NEW_ERROR(isolate,
|
| NewReferenceError(MessageTemplate::kNotDefined, name),
|
|
|