OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 void MacroAssembler::LoadContext(Register dst, int context_chain_length) { | 1516 void MacroAssembler::LoadContext(Register dst, int context_chain_length) { |
1517 if (context_chain_length > 0) { | 1517 if (context_chain_length > 0) { |
1518 // Move up the chain of contexts to the context containing the slot. | 1518 // Move up the chain of contexts to the context containing the slot. |
1519 mov(dst, Operand(esi, Context::SlotOffset(Context::CLOSURE_INDEX))); | 1519 mov(dst, Operand(esi, Context::SlotOffset(Context::CLOSURE_INDEX))); |
1520 // Load the function context (which is the incoming, outer context). | 1520 // Load the function context (which is the incoming, outer context). |
1521 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); | 1521 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
1522 for (int i = 1; i < context_chain_length; i++) { | 1522 for (int i = 1; i < context_chain_length; i++) { |
1523 mov(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); | 1523 mov(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); |
1524 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); | 1524 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
1525 } | 1525 } |
1526 // The context may be an intermediate context, not a function context. | 1526 } else { |
1527 mov(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); | 1527 // Slot is in the current function context. Move it into the |
1528 } else { // Slot is in the current function context. | 1528 // destination register in case we store into it (the write barrier |
1529 // The context may be an intermediate context, not a function context. | 1529 // cannot be allowed to destroy the context in esi). |
1530 mov(dst, Operand(esi, Context::SlotOffset(Context::FCONTEXT_INDEX))); | 1530 mov(dst, esi); |
| 1531 } |
| 1532 |
| 1533 // We should not have found a 'with' context by walking the context chain |
| 1534 // (i.e., the static scope chain and runtime context chain do not agree). |
| 1535 // A variable occurring in such a scope should have slot type LOOKUP and |
| 1536 // not CONTEXT. |
| 1537 if (FLAG_debug_code) { |
| 1538 cmp(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
| 1539 Check(equal, "Yo dawg, I heard you liked function contexts " |
| 1540 "so I put function contexts in all your contexts"); |
1531 } | 1541 } |
1532 } | 1542 } |
1533 | 1543 |
1534 | 1544 |
1535 void MacroAssembler::LoadGlobalFunction(int index, Register function) { | 1545 void MacroAssembler::LoadGlobalFunction(int index, Register function) { |
1536 // Load the global or builtins object from the current context. | 1546 // Load the global or builtins object from the current context. |
1537 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 1547 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
1538 // Load the global context from the global or builtins object. | 1548 // Load the global context from the global or builtins object. |
1539 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); | 1549 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); |
1540 // Load the function from the global context. | 1550 // Load the function from the global context. |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 | 1899 |
1890 // Check that the code was patched as expected. | 1900 // Check that the code was patched as expected. |
1891 ASSERT(masm_.pc_ == address_ + size_); | 1901 ASSERT(masm_.pc_ == address_ + size_); |
1892 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1902 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
1893 } | 1903 } |
1894 | 1904 |
1895 | 1905 |
1896 } } // namespace v8::internal | 1906 } } // namespace v8::internal |
1897 | 1907 |
1898 #endif // V8_TARGET_ARCH_IA32 | 1908 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |