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

Side by Side Diff: src/ia32/full-codegen-ia32.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_IA32 7 #if V8_TARGET_ARCH_IA32
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 2646 matching lines...) Expand 10 before | Expand all | Expand 10 after
2657 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2657 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2658 Label assign; 2658 Label assign;
2659 MemOperand location = VarOperand(var, ecx); 2659 MemOperand location = VarOperand(var, ecx);
2660 __ mov(edx, location); 2660 __ mov(edx, location);
2661 __ cmp(edx, isolate()->factory()->the_hole_value()); 2661 __ cmp(edx, isolate()->factory()->the_hole_value());
2662 __ j(not_equal, &assign, Label::kNear); 2662 __ j(not_equal, &assign, Label::kNear);
2663 __ push(Immediate(var->name())); 2663 __ push(Immediate(var->name()));
2664 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2664 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2665 __ bind(&assign); 2665 __ bind(&assign);
2666 EmitStoreToStackLocalOrContextSlot(var, location); 2666 EmitStoreToStackLocalOrContextSlot(var, location);
2667 } else if (var->mode() == CONST && op != Token::INIT_CONST) {
2668 // Assignment to let variable needs a write barrier.
2669 DCHECK(!var->IsLookupSlot());
2670 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2671 Label const_error;
2672 MemOperand location = VarOperand(var, ecx);
2673 __ mov(edx, location);
2674 __ cmp(edx, isolate()->factory()->the_hole_value());
2675 __ j(not_equal, &const_error, Label::kNear);
2676 __ push(Immediate(var->name()));
2677 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2678 __ bind(&const_error);
2679 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2667 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { 2680 } else if (!var->is_const_mode() || op == Token::INIT_CONST) {
2668 if (var->IsLookupSlot()) { 2681 if (var->IsLookupSlot()) {
2669 // Assignment to var. 2682 // Assignment to var.
2670 __ push(eax); // Value. 2683 __ push(eax); // Value.
2671 __ push(esi); // Context. 2684 __ push(esi); // Context.
2672 __ push(Immediate(var->name())); 2685 __ push(Immediate(var->name()));
2673 __ push(Immediate(Smi::FromInt(language_mode()))); 2686 __ push(Immediate(Smi::FromInt(language_mode())));
2674 __ CallRuntime(Runtime::kStoreLookupSlot, 4); 2687 __ CallRuntime(Runtime::kStoreLookupSlot, 4);
2675 } else { 2688 } else {
2676 // Assignment to var or initializing assignment to let/const in harmony 2689 // Assignment to var or initializing assignment to let/const in harmony
(...skipping 2687 matching lines...) Expand 10 before | Expand all | Expand 10 after
5364 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5377 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5365 Assembler::target_address_at(call_target_address, 5378 Assembler::target_address_at(call_target_address,
5366 unoptimized_code)); 5379 unoptimized_code));
5367 return OSR_AFTER_STACK_CHECK; 5380 return OSR_AFTER_STACK_CHECK;
5368 } 5381 }
5369 5382
5370 5383
5371 } } // namespace v8::internal 5384 } } // namespace v8::internal
5372 5385
5373 #endif // V8_TARGET_ARCH_IA32 5386 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698