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

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

Issue 159903008: Fix assignment of function name constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: changed test Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | test/mjsunit/regress/regress-3138.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 ? isolate()->builtins()->KeyedStoreIC_Initialize() 2393 ? isolate()->builtins()->KeyedStoreIC_Initialize()
2394 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); 2394 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
2395 CallIC(ic); 2395 CallIC(ic);
2396 break; 2396 break;
2397 } 2397 }
2398 } 2398 }
2399 context()->Plug(rax); 2399 context()->Plug(rax);
2400 } 2400 }
2401 2401
2402 2402
2403 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot(
2404 Variable* var, MemOperand location) {
2405 __ movp(location, rax);
2406 if (var->IsContextSlot()) {
2407 __ movp(rdx, rax);
2408 __ RecordWriteContextSlot(
2409 rcx, Context::SlotOffset(var->index()), rdx, rbx, kDontSaveFPRegs);
2410 }
2411 }
2412
2413
2414 void FullCodeGenerator::EmitCallStoreContextSlot(
2415 Handle<String> name, LanguageMode mode) {
2416 __ push(rax); // Value.
2417 __ push(rsi); // Context.
2418 __ Push(name);
2419 __ Push(Smi::FromInt(mode));
2420 __ CallRuntime(Runtime::kStoreContextSlot, 4);
2421 }
2422
2423
2403 void FullCodeGenerator::EmitVariableAssignment(Variable* var, 2424 void FullCodeGenerator::EmitVariableAssignment(Variable* var,
2404 Token::Value op) { 2425 Token::Value op) {
2405 if (var->IsUnallocated()) { 2426 if (var->IsUnallocated()) {
2406 // Global var, const, or let. 2427 // Global var, const, or let.
2407 __ Move(rcx, var->name()); 2428 __ Move(rcx, var->name());
2408 __ movp(rdx, GlobalObjectOperand()); 2429 __ movp(rdx, GlobalObjectOperand());
2409 CallStoreIC(); 2430 CallStoreIC();
2431
2410 } else if (op == Token::INIT_CONST) { 2432 } else if (op == Token::INIT_CONST) {
2411 // Const initializers need a write barrier. 2433 // Const initializers need a write barrier.
2412 ASSERT(!var->IsParameter()); // No const parameters. 2434 ASSERT(!var->IsParameter()); // No const parameters.
2413 if (var->IsStackLocal()) { 2435 if (var->IsLookupSlot()) {
2414 Label skip;
2415 __ movp(rdx, StackOperand(var));
2416 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2417 __ j(not_equal, &skip);
2418 __ movp(StackOperand(var), rax);
2419 __ bind(&skip);
2420 } else {
2421 ASSERT(var->IsContextSlot() || var->IsLookupSlot());
2422 // Like var declarations, const declarations are hoisted to function
2423 // scope. However, unlike var initializers, const initializers are
2424 // able to drill a hole to that function context, even from inside a
2425 // 'with' context. We thus bypass the normal static scope lookup for
2426 // var->IsContextSlot().
2427 __ push(rax); 2436 __ push(rax);
2428 __ push(rsi); 2437 __ push(rsi);
2429 __ Push(var->name()); 2438 __ Push(var->name());
2430 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); 2439 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3);
2440 } else {
2441 ASSERT(var->IsStackLocal() || var->IsContextSlot());
2442 Label skip;
2443 MemOperand location = VarOperand(var, rcx);
2444 __ movp(rdx, location);
2445 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2446 __ j(not_equal, &skip);
2447 EmitStoreToStackLocalOrContextSlot(var, location);
2448 __ bind(&skip);
2431 } 2449 }
2432 2450
2433 } else if (var->mode() == LET && op != Token::INIT_LET) { 2451 } else if (var->mode() == LET && op != Token::INIT_LET) {
2434 // Non-initializing assignment to let variable needs a write barrier. 2452 // Non-initializing assignment to let variable needs a write barrier.
2435 if (var->IsLookupSlot()) { 2453 if (var->IsLookupSlot()) {
2436 __ push(rax); // Value. 2454 EmitCallStoreContextSlot(var->name(), language_mode());
2437 __ push(rsi); // Context.
2438 __ Push(var->name());
2439 __ Push(Smi::FromInt(language_mode()));
2440 __ CallRuntime(Runtime::kStoreContextSlot, 4);
2441 } else { 2455 } else {
2442 ASSERT(var->IsStackAllocated() || var->IsContextSlot()); 2456 ASSERT(var->IsStackAllocated() || var->IsContextSlot());
2443 Label assign; 2457 Label assign;
2444 MemOperand location = VarOperand(var, rcx); 2458 MemOperand location = VarOperand(var, rcx);
2445 __ movp(rdx, location); 2459 __ movp(rdx, location);
2446 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2460 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2447 __ j(not_equal, &assign, Label::kNear); 2461 __ j(not_equal, &assign, Label::kNear);
2448 __ Push(var->name()); 2462 __ Push(var->name());
2449 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2463 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2450 __ bind(&assign); 2464 __ bind(&assign);
2451 __ movp(location, rax); 2465 EmitStoreToStackLocalOrContextSlot(var, location);
2452 if (var->IsContextSlot()) {
2453 __ movp(rdx, rax);
2454 __ RecordWriteContextSlot(
2455 rcx, Context::SlotOffset(var->index()), rdx, rbx, kDontSaveFPRegs);
2456 }
2457 } 2466 }
2458 2467
2459 } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) { 2468 } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) {
2460 // Assignment to var or initializing assignment to let/const 2469 // Assignment to var or initializing assignment to let/const
2461 // in harmony mode. 2470 // in harmony mode.
2462 if (var->IsStackAllocated() || var->IsContextSlot()) { 2471 if (var->IsLookupSlot()) {
2472 EmitCallStoreContextSlot(var->name(), language_mode());
2473 } else {
2474 ASSERT(var->IsStackAllocated() || var->IsContextSlot());
2463 MemOperand location = VarOperand(var, rcx); 2475 MemOperand location = VarOperand(var, rcx);
2464 if (generate_debug_code_ && op == Token::INIT_LET) { 2476 if (generate_debug_code_ && op == Token::INIT_LET) {
2465 // Check for an uninitialized let binding. 2477 // Check for an uninitialized let binding.
2466 __ movp(rdx, location); 2478 __ movp(rdx, location);
2467 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2479 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2468 __ Check(equal, kLetBindingReInitialization); 2480 __ Check(equal, kLetBindingReInitialization);
2469 } 2481 }
2470 // Perform the assignment. 2482 EmitStoreToStackLocalOrContextSlot(var, location);
2471 __ movp(location, rax);
2472 if (var->IsContextSlot()) {
2473 __ movp(rdx, rax);
2474 __ RecordWriteContextSlot(
2475 rcx, Context::SlotOffset(var->index()), rdx, rbx, kDontSaveFPRegs);
2476 }
2477 } else {
2478 ASSERT(var->IsLookupSlot());
2479 __ push(rax); // Value.
2480 __ push(rsi); // Context.
2481 __ Push(var->name());
2482 __ Push(Smi::FromInt(language_mode()));
2483 __ CallRuntime(Runtime::kStoreContextSlot, 4);
2484 } 2483 }
2485 } 2484 }
2486 // Non-initializing assignments to consts are ignored. 2485 // Non-initializing assignments to consts are ignored.
2487 } 2486 }
2488 2487
2489 2488
2490 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2489 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2491 // Assignment to a property, using a named store IC. 2490 // Assignment to a property, using a named store IC.
2492 Property* prop = expr->target()->AsProperty(); 2491 Property* prop = expr->target()->AsProperty();
2493 ASSERT(prop != NULL); 2492 ASSERT(prop != NULL);
(...skipping 2414 matching lines...) Expand 10 before | Expand all | Expand 10 after
4908 4907
4909 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4908 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4910 Assembler::target_address_at(call_target_address)); 4909 Assembler::target_address_at(call_target_address));
4911 return OSR_AFTER_STACK_CHECK; 4910 return OSR_AFTER_STACK_CHECK;
4912 } 4911 }
4913 4912
4914 4913
4915 } } // namespace v8::internal 4914 } } // namespace v8::internal
4916 4915
4917 #endif // V8_TARGET_ARCH_X64 4916 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | test/mjsunit/regress/regress-3138.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698