Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: src/runtime/runtime-scopes.cc

Issue 1113133006: Revert of Resolve references to "this" the same way as normal variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/scopeinfo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (attributes != ABSENT && holder->IsJSGlobalObject()) { 243 if (attributes != ABSENT && holder->IsJSGlobalObject()) {
244 return DeclareGlobals(isolate, Handle<JSGlobalObject>::cast(holder), name, 244 return DeclareGlobals(isolate, Handle<JSGlobalObject>::cast(holder), name,
245 value, attr, is_var, is_const, is_function); 245 value, attr, is_var, is_const, is_function);
246 } 246 }
247 if (context_arg->has_extension() && 247 if (context_arg->has_extension() &&
248 context_arg->extension()->IsJSGlobalObject()) { 248 context_arg->extension()->IsJSGlobalObject()) {
249 Handle<JSGlobalObject> global( 249 Handle<JSGlobalObject> global(
250 JSGlobalObject::cast(context_arg->extension()), isolate); 250 JSGlobalObject::cast(context_arg->extension()), isolate);
251 return DeclareGlobals(isolate, global, name, value, attr, is_var, is_const, 251 return DeclareGlobals(isolate, global, name, value, attr, is_var, is_const,
252 is_function); 252 is_function);
253 } else if (context->IsScriptContext()) {
254 DCHECK(context->global_object()->IsJSGlobalObject());
255 Handle<JSGlobalObject> global(
256 JSGlobalObject::cast(context->global_object()), isolate);
257 return DeclareGlobals(isolate, global, name, value, attr, is_var, is_const,
258 is_function);
259 } 253 }
260 254
261 if (attributes != ABSENT) { 255 if (attributes != ABSENT) {
262 // The name was declared before; check for conflicting re-declarations. 256 // The name was declared before; check for conflicting re-declarations.
263 if (is_const || (attributes & READ_ONLY) != 0) { 257 if (is_const || (attributes & READ_ONLY) != 0) {
264 return ThrowRedeclarationError(isolate, name); 258 return ThrowRedeclarationError(isolate, name);
265 } 259 }
266 260
267 // Skip var re-declarations. 261 // Skip var re-declarations.
268 if (is_var) return isolate->heap()->undefined_value(); 262 if (is_var) return isolate->heap()->undefined_value();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 PropertyAttributes attr = 318 PropertyAttributes attr =
325 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 319 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
326 320
327 // Strict mode handling not needed (legacy const is disallowed in strict 321 // Strict mode handling not needed (legacy const is disallowed in strict
328 // mode). 322 // mode).
329 323
330 // The declared const was configurable, and may have been deleted in the 324 // The declared const was configurable, and may have been deleted in the
331 // meanwhile. If so, re-introduce the variable in the context extension. 325 // meanwhile. If so, re-introduce the variable in the context extension.
332 if (attributes == ABSENT) { 326 if (attributes == ABSENT) {
333 Handle<Context> declaration_context(context_arg->declaration_context()); 327 Handle<Context> declaration_context(context_arg->declaration_context());
334 if (declaration_context->IsScriptContext()) { 328 DCHECK(declaration_context->has_extension());
335 holder = handle(declaration_context->global_object(), isolate); 329 holder = handle(declaration_context->extension(), isolate);
336 } else {
337 DCHECK(declaration_context->has_extension());
338 holder = handle(declaration_context->extension(), isolate);
339 }
340 CHECK(holder->IsJSObject()); 330 CHECK(holder->IsJSObject());
341 } else { 331 } else {
342 // For JSContextExtensionObjects, the initializer can be run multiple times 332 // For JSContextExtensionObjects, the initializer can be run multiple times
343 // if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the 333 // if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the
344 // first assignment should go through. For JSGlobalObjects, additionally any 334 // first assignment should go through. For JSGlobalObjects, additionally any
345 // code can run in between that modifies the declared property. 335 // code can run in between that modifies the declared property.
346 DCHECK(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject()); 336 DCHECK(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject());
347 337
348 LookupIterator it(holder, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 338 LookupIterator it(holder, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
349 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 339 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 Handle<GlobalObject> global_object(function->context()->global_object()); 623 Handle<GlobalObject> global_object(function->context()->global_object());
634 Handle<Context> native_context(global_object->native_context()); 624 Handle<Context> native_context(global_object->native_context());
635 Handle<ScriptContextTable> script_context_table( 625 Handle<ScriptContextTable> script_context_table(
636 native_context->script_context_table()); 626 native_context->script_context_table());
637 627
638 Handle<String> clashed_name; 628 Handle<String> clashed_name;
639 Object* name_clash_result = 629 Object* name_clash_result =
640 FindNameClash(scope_info, global_object, script_context_table); 630 FindNameClash(scope_info, global_object, script_context_table);
641 if (isolate->has_pending_exception()) return name_clash_result; 631 if (isolate->has_pending_exception()) return name_clash_result;
642 632
643 // Script contexts have a canonical empty function as their closure, not the
644 // anonymous closure containing the global code. See
645 // FullCodeGenerator::PushFunctionArgumentForContextAllocation.
646 Handle<JSFunction> closure(native_context->closure());
647 Handle<Context> result = 633 Handle<Context> result =
648 isolate->factory()->NewScriptContext(closure, scope_info); 634 isolate->factory()->NewScriptContext(function, scope_info);
649 635
650 DCHECK(function->context() == isolate->context()); 636 DCHECK(function->context() == isolate->context());
651 DCHECK(function->context()->global_object() == result->global_object()); 637 DCHECK(function->context()->global_object() == result->global_object());
652 638
653 Handle<ScriptContextTable> new_script_context_table = 639 Handle<ScriptContextTable> new_script_context_table =
654 ScriptContextTable::Extend(script_context_table, result); 640 ScriptContextTable::Extend(script_context_table, result);
655 native_context->set_script_context_table(*new_script_context_table); 641 native_context->set_script_context_table(*new_script_context_table);
656 return *result; 642 return *result;
657 } 643 }
658 644
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 return Smi::FromInt(frame->GetArgumentsLength()); 1120 return Smi::FromInt(frame->GetArgumentsLength());
1135 } 1121 }
1136 1122
1137 1123
1138 RUNTIME_FUNCTION(Runtime_Arguments) { 1124 RUNTIME_FUNCTION(Runtime_Arguments) {
1139 SealHandleScope shs(isolate); 1125 SealHandleScope shs(isolate);
1140 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); 1126 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate);
1141 } 1127 }
1142 } 1128 }
1143 } // namespace v8::internal 1129 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698