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

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 976053002: Fix exception for assignment to uninitialised const (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Jeez Created 5 years, 9 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2650 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 Label assign; 2661 Label assign;
2662 MemOperand location = VarOperand(var, rcx); 2662 MemOperand location = VarOperand(var, rcx);
2663 __ movp(rdx, location); 2663 __ movp(rdx, location);
2664 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2664 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2665 __ j(not_equal, &assign, Label::kNear); 2665 __ j(not_equal, &assign, Label::kNear);
2666 __ Push(var->name()); 2666 __ Push(var->name());
2667 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2667 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2668 __ bind(&assign); 2668 __ bind(&assign);
2669 EmitStoreToStackLocalOrContextSlot(var, location); 2669 EmitStoreToStackLocalOrContextSlot(var, location);
2670 2670
2671 } else if (var->mode() == CONST && op != Token::INIT_CONST) {
2672 // Assignment to const variable needs a write barrier.
2673 DCHECK(!var->IsLookupSlot());
2674 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2675 Label const_error;
2676 MemOperand location = VarOperand(var, rcx);
2677 __ movp(rdx, location);
2678 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2679 __ j(not_equal, &const_error, Label::kNear);
2680 __ Push(var->name());
2681 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2682 __ bind(&const_error);
2683 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2684
2671 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { 2685 } else if (!var->is_const_mode() || op == Token::INIT_CONST) {
2672 if (var->IsLookupSlot()) { 2686 if (var->IsLookupSlot()) {
2673 // Assignment to var. 2687 // Assignment to var.
2674 __ Push(rax); // Value. 2688 __ Push(rax); // Value.
2675 __ Push(rsi); // Context. 2689 __ Push(rsi); // Context.
2676 __ Push(var->name()); 2690 __ Push(var->name());
2677 __ Push(Smi::FromInt(language_mode())); 2691 __ Push(Smi::FromInt(language_mode()));
2678 __ CallRuntime(Runtime::kStoreLookupSlot, 4); 2692 __ CallRuntime(Runtime::kStoreLookupSlot, 4);
2679 } else { 2693 } else {
2680 // Assignment to var or initializing assignment to let/const in harmony 2694 // Assignment to var or initializing assignment to let/const in harmony
(...skipping 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after
5386 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5400 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5387 Assembler::target_address_at(call_target_address, 5401 Assembler::target_address_at(call_target_address,
5388 unoptimized_code)); 5402 unoptimized_code));
5389 return OSR_AFTER_STACK_CHECK; 5403 return OSR_AFTER_STACK_CHECK;
5390 } 5404 }
5391 5405
5392 5406
5393 } } // namespace v8::internal 5407 } } // namespace v8::internal
5394 5408
5395 #endif // V8_TARGET_ARCH_X64 5409 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698