| OLD | NEW |
| 1 // Copyright 2010 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 movq(index, BitCast<int64_t>(kZapValue), RelocInfo::NONE); | 129 movq(index, BitCast<int64_t>(kZapValue), RelocInfo::NONE); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 | 133 |
| 134 void MacroAssembler::RecordWrite(Register object, | 134 void MacroAssembler::RecordWrite(Register object, |
| 135 Register address, | 135 Register address, |
| 136 Register value) { | 136 Register value) { |
| 137 // The compiled code assumes that record write doesn't change the | 137 // The compiled code assumes that record write doesn't change the |
| 138 // context register, so we check that none of the clobbered | 138 // context register, so we check that none of the clobbered |
| 139 // registers are esi. | 139 // registers are rsi. |
| 140 ASSERT(!object.is(rsi) && !value.is(rsi) && !address.is(rsi)); | 140 ASSERT(!object.is(rsi) && !value.is(rsi) && !address.is(rsi)); |
| 141 | 141 |
| 142 // First, check if a write barrier is even needed. The tests below | 142 // First, check if a write barrier is even needed. The tests below |
| 143 // catch stores of Smis and stores into young gen. | 143 // catch stores of Smis and stores into young gen. |
| 144 Label done; | 144 Label done; |
| 145 JumpIfSmi(value, &done); | 145 JumpIfSmi(value, &done); |
| 146 | 146 |
| 147 InNewSpace(object, value, equal, &done); | 147 InNewSpace(object, value, equal, &done); |
| 148 | 148 |
| 149 RecordWriteHelper(object, address, value); | 149 RecordWriteHelper(object, address, value); |
| (...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 10, | 1496 10, |
| 1497 -1 | 1497 -1 |
| 1498 }; | 1498 }; |
| 1499 | 1499 |
| 1500 | 1500 |
| 1501 void MacroAssembler::StoreToSafepointRegisterSlot(Register dst, Register src) { | 1501 void MacroAssembler::StoreToSafepointRegisterSlot(Register dst, Register src) { |
| 1502 movq(SafepointRegisterSlot(dst), src); | 1502 movq(SafepointRegisterSlot(dst), src); |
| 1503 } | 1503 } |
| 1504 | 1504 |
| 1505 | 1505 |
| 1506 void MacroAssembler::LoadFromSafepointRegisterSlot(Register dst, Register src) { |
| 1507 movq(dst, SafepointRegisterSlot(src)); |
| 1508 } |
| 1509 |
| 1510 |
| 1506 Operand MacroAssembler::SafepointRegisterSlot(Register reg) { | 1511 Operand MacroAssembler::SafepointRegisterSlot(Register reg) { |
| 1507 return Operand(rsp, SafepointRegisterStackIndex(reg.code()) * kPointerSize); | 1512 return Operand(rsp, SafepointRegisterStackIndex(reg.code()) * kPointerSize); |
| 1508 } | 1513 } |
| 1509 | 1514 |
| 1510 | 1515 |
| 1511 void MacroAssembler::PushTryHandler(CodeLocation try_location, | 1516 void MacroAssembler::PushTryHandler(CodeLocation try_location, |
| 1512 HandlerType type) { | 1517 HandlerType type) { |
| 1513 // Adjust this code if not the case. | 1518 // Adjust this code if not the case. |
| 1514 ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); | 1519 ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); |
| 1515 | 1520 |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 // Move up the chain of contexts to the context containing the slot. | 2529 // Move up the chain of contexts to the context containing the slot. |
| 2525 movq(dst, Operand(rsi, Context::SlotOffset(Context::CLOSURE_INDEX))); | 2530 movq(dst, Operand(rsi, Context::SlotOffset(Context::CLOSURE_INDEX))); |
| 2526 // Load the function context (which is the incoming, outer context). | 2531 // Load the function context (which is the incoming, outer context). |
| 2527 movq(dst, FieldOperand(dst, JSFunction::kContextOffset)); | 2532 movq(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
| 2528 for (int i = 1; i < context_chain_length; i++) { | 2533 for (int i = 1; i < context_chain_length; i++) { |
| 2529 movq(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); | 2534 movq(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); |
| 2530 movq(dst, FieldOperand(dst, JSFunction::kContextOffset)); | 2535 movq(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
| 2531 } | 2536 } |
| 2532 // The context may be an intermediate context, not a function context. | 2537 // The context may be an intermediate context, not a function context. |
| 2533 movq(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); | 2538 movq(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
| 2534 } else { // context is the current function context. | 2539 } else { |
| 2535 // The context may be an intermediate context, not a function context. | 2540 // Slot is in the current function context. Move it into the |
| 2536 movq(dst, Operand(rsi, Context::SlotOffset(Context::FCONTEXT_INDEX))); | 2541 // destination register in case we store into it (the write barrier |
| 2542 // cannot be allowed to destroy the context in rsi). |
| 2543 movq(dst, rsi); |
| 2544 } |
| 2545 |
| 2546 // We should not have found a 'with' context by walking the context chain |
| 2547 // (i.e., the static scope chain and runtime context chain do not agree). |
| 2548 // A variable occurring in such a scope should have slot type LOOKUP and |
| 2549 // not CONTEXT. |
| 2550 if (FLAG_debug_code) { |
| 2551 cmpq(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
| 2552 Check(equal, "Yo dawg, I heard you liked function contexts " |
| 2553 "so I put function contexts in all your contexts"); |
| 2537 } | 2554 } |
| 2538 } | 2555 } |
| 2539 | 2556 |
| 2540 | 2557 |
| 2541 void MacroAssembler::LoadGlobalFunction(int index, Register function) { | 2558 void MacroAssembler::LoadGlobalFunction(int index, Register function) { |
| 2542 // Load the global or builtins object from the current context. | 2559 // Load the global or builtins object from the current context. |
| 2543 movq(function, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 2560 movq(function, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 2544 // Load the global context from the global or builtins object. | 2561 // Load the global context from the global or builtins object. |
| 2545 movq(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); | 2562 movq(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); |
| 2546 // Load the function from the global context. | 2563 // Load the function from the global context. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2634 CPU::FlushICache(address_, size_); | 2651 CPU::FlushICache(address_, size_); |
| 2635 | 2652 |
| 2636 // Check that the code was patched as expected. | 2653 // Check that the code was patched as expected. |
| 2637 ASSERT(masm_.pc_ == address_ + size_); | 2654 ASSERT(masm_.pc_ == address_ + size_); |
| 2638 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2655 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2639 } | 2656 } |
| 2640 | 2657 |
| 2641 } } // namespace v8::internal | 2658 } } // namespace v8::internal |
| 2642 | 2659 |
| 2643 #endif // V8_TARGET_ARCH_X64 | 2660 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |