OLD | NEW |
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 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 | 1412 |
1413 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { | 1413 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { |
1414 // Record position before possible IC call. | 1414 // Record position before possible IC call. |
1415 SetSourcePosition(proxy->position()); | 1415 SetSourcePosition(proxy->position()); |
1416 Variable* var = proxy->var(); | 1416 Variable* var = proxy->var(); |
1417 | 1417 |
1418 // Three cases: global variables, lookup variables, and all other types of | 1418 // Three cases: global variables, lookup variables, and all other types of |
1419 // variables. | 1419 // variables. |
1420 switch (var->location()) { | 1420 switch (var->location()) { |
1421 case Variable::UNALLOCATED: { | 1421 case Variable::UNALLOCATED: { |
1422 Comment cmnt(masm_, "Global variable"); | 1422 Comment cmnt(masm_, "[ Global variable"); |
1423 // Use inline caching. Variable name is passed in ecx and the global | 1423 // Use inline caching. Variable name is passed in ecx and the global |
1424 // object in eax. | 1424 // object in eax. |
1425 __ mov(edx, GlobalObjectOperand()); | 1425 __ mov(edx, GlobalObjectOperand()); |
1426 __ mov(ecx, var->name()); | 1426 __ mov(ecx, var->name()); |
1427 CallLoadIC(CONTEXTUAL); | 1427 CallLoadIC(CONTEXTUAL); |
1428 context()->Plug(eax); | 1428 context()->Plug(eax); |
1429 break; | 1429 break; |
1430 } | 1430 } |
1431 | 1431 |
1432 case Variable::PARAMETER: | 1432 case Variable::PARAMETER: |
1433 case Variable::LOCAL: | 1433 case Variable::LOCAL: |
1434 case Variable::CONTEXT: { | 1434 case Variable::CONTEXT: { |
1435 Comment cmnt(masm_, var->IsContextSlot() | 1435 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
1436 ? "Context variable" | 1436 : "[ Stack variable"); |
1437 : "Stack variable"); | |
1438 if (var->binding_needs_init()) { | 1437 if (var->binding_needs_init()) { |
1439 // var->scope() may be NULL when the proxy is located in eval code and | 1438 // var->scope() may be NULL when the proxy is located in eval code and |
1440 // refers to a potential outside binding. Currently those bindings are | 1439 // refers to a potential outside binding. Currently those bindings are |
1441 // always looked up dynamically, i.e. in that case | 1440 // always looked up dynamically, i.e. in that case |
1442 // var->location() == LOOKUP. | 1441 // var->location() == LOOKUP. |
1443 // always holds. | 1442 // always holds. |
1444 ASSERT(var->scope() != NULL); | 1443 ASSERT(var->scope() != NULL); |
1445 | 1444 |
1446 // Check if the binding really needs an initialization check. The check | 1445 // Check if the binding really needs an initialization check. The check |
1447 // can be skipped in the following situation: we have a LET or CONST | 1446 // can be skipped in the following situation: we have a LET or CONST |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 __ bind(&done); | 1488 __ bind(&done); |
1490 context()->Plug(eax); | 1489 context()->Plug(eax); |
1491 break; | 1490 break; |
1492 } | 1491 } |
1493 } | 1492 } |
1494 context()->Plug(var); | 1493 context()->Plug(var); |
1495 break; | 1494 break; |
1496 } | 1495 } |
1497 | 1496 |
1498 case Variable::LOOKUP: { | 1497 case Variable::LOOKUP: { |
| 1498 Comment cmnt(masm_, "[ Lookup variable"); |
1499 Label done, slow; | 1499 Label done, slow; |
1500 // Generate code for loading from variables potentially shadowed | 1500 // Generate code for loading from variables potentially shadowed |
1501 // by eval-introduced variables. | 1501 // by eval-introduced variables. |
1502 EmitDynamicLookupFastCase(var, NOT_INSIDE_TYPEOF, &slow, &done); | 1502 EmitDynamicLookupFastCase(var, NOT_INSIDE_TYPEOF, &slow, &done); |
1503 __ bind(&slow); | 1503 __ bind(&slow); |
1504 Comment cmnt(masm_, "Lookup variable"); | |
1505 __ push(esi); // Context. | 1504 __ push(esi); // Context. |
1506 __ push(Immediate(var->name())); | 1505 __ push(Immediate(var->name())); |
1507 __ CallRuntime(Runtime::kLoadContextSlot, 2); | 1506 __ CallRuntime(Runtime::kLoadContextSlot, 2); |
1508 __ bind(&done); | 1507 __ bind(&done); |
1509 context()->Plug(eax); | 1508 context()->Plug(eax); |
1510 break; | 1509 break; |
1511 } | 1510 } |
1512 } | 1511 } |
1513 } | 1512 } |
1514 | 1513 |
(...skipping 2967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4482 } | 4481 } |
4483 } | 4482 } |
4484 | 4483 |
4485 | 4484 |
4486 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4485 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
4487 VariableProxy* proxy = expr->AsVariableProxy(); | 4486 VariableProxy* proxy = expr->AsVariableProxy(); |
4488 ASSERT(!context()->IsEffect()); | 4487 ASSERT(!context()->IsEffect()); |
4489 ASSERT(!context()->IsTest()); | 4488 ASSERT(!context()->IsTest()); |
4490 | 4489 |
4491 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4490 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
4492 Comment cmnt(masm_, "Global variable"); | 4491 Comment cmnt(masm_, "[ Global variable"); |
4493 __ mov(edx, GlobalObjectOperand()); | 4492 __ mov(edx, GlobalObjectOperand()); |
4494 __ mov(ecx, Immediate(proxy->name())); | 4493 __ mov(ecx, Immediate(proxy->name())); |
4495 // Use a regular load, not a contextual load, to avoid a reference | 4494 // Use a regular load, not a contextual load, to avoid a reference |
4496 // error. | 4495 // error. |
4497 CallLoadIC(NOT_CONTEXTUAL); | 4496 CallLoadIC(NOT_CONTEXTUAL); |
4498 PrepareForBailout(expr, TOS_REG); | 4497 PrepareForBailout(expr, TOS_REG); |
4499 context()->Plug(eax); | 4498 context()->Plug(eax); |
4500 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 4499 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
| 4500 Comment cmnt(masm_, "[ Lookup slot"); |
4501 Label done, slow; | 4501 Label done, slow; |
4502 | 4502 |
4503 // Generate code for loading from variables potentially shadowed | 4503 // Generate code for loading from variables potentially shadowed |
4504 // by eval-introduced variables. | 4504 // by eval-introduced variables. |
4505 EmitDynamicLookupFastCase(proxy->var(), INSIDE_TYPEOF, &slow, &done); | 4505 EmitDynamicLookupFastCase(proxy->var(), INSIDE_TYPEOF, &slow, &done); |
4506 | 4506 |
4507 __ bind(&slow); | 4507 __ bind(&slow); |
4508 __ push(esi); | 4508 __ push(esi); |
4509 __ push(Immediate(proxy->name())); | 4509 __ push(Immediate(proxy->name())); |
4510 __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2); | 4510 __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2); |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4913 | 4913 |
4914 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4914 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4915 Assembler::target_address_at(call_target_address)); | 4915 Assembler::target_address_at(call_target_address)); |
4916 return OSR_AFTER_STACK_CHECK; | 4916 return OSR_AFTER_STACK_CHECK; |
4917 } | 4917 } |
4918 | 4918 |
4919 | 4919 |
4920 } } // namespace v8::internal | 4920 } } // namespace v8::internal |
4921 | 4921 |
4922 #endif // V8_TARGET_ARCH_IA32 | 4922 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |