OLD | NEW |
(Empty) | |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #include "v8.h" |
| 29 |
| 30 #include "cfg.h" |
| 31 #include "codegen-inl.h" |
| 32 #include "macro-assembler-ia32.h" |
| 33 |
| 34 namespace v8 { |
| 35 namespace internal { |
| 36 |
| 37 #define __ ACCESS_MASM(masm) |
| 38 |
| 39 void InstructionBlock::Compile(MacroAssembler* masm) { |
| 40 ASSERT(!is_marked()); |
| 41 is_marked_ = true; |
| 42 { |
| 43 Comment cmt(masm, "[ InstructionBlock"); |
| 44 for (int i = 0, len = instructions_.length(); i < len; i++) { |
| 45 instructions_[i]->Compile(masm); |
| 46 } |
| 47 } |
| 48 successor_->Compile(masm); |
| 49 } |
| 50 |
| 51 |
| 52 void EntryNode::Compile(MacroAssembler* masm) { |
| 53 ASSERT(!is_marked()); |
| 54 is_marked_ = true; |
| 55 Label deferred_enter, deferred_exit; |
| 56 { |
| 57 Comment cmnt(masm, "[ EntryNode"); |
| 58 __ push(ebp); |
| 59 __ mov(ebp, esp); |
| 60 __ push(esi); |
| 61 __ push(edi); |
| 62 if (local_count_ > 0) { |
| 63 __ Set(eax, Immediate(Factory::undefined_value())); |
| 64 for (int i = 0; i < local_count_; i++) { |
| 65 __ push(eax); |
| 66 } |
| 67 } |
| 68 if (FLAG_check_stack) { |
| 69 ExternalReference stack_limit = |
| 70 ExternalReference::address_of_stack_guard_limit(); |
| 71 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
| 72 __ j(below, &deferred_enter); |
| 73 __ bind(&deferred_exit); |
| 74 } |
| 75 } |
| 76 successor_->Compile(masm); |
| 77 if (FLAG_check_stack) { |
| 78 __ bind(&deferred_enter); |
| 79 StackCheckStub stub; |
| 80 __ CallStub(&stub); |
| 81 __ jmp(&deferred_exit); |
| 82 } |
| 83 } |
| 84 |
| 85 |
| 86 void ExitNode::Compile(MacroAssembler* masm) { |
| 87 ASSERT(!is_marked()); |
| 88 is_marked_ = true; |
| 89 Comment cmnt(masm, "[ ExitNode"); |
| 90 __ RecordJSReturn(); |
| 91 __ mov(esp, ebp); |
| 92 __ pop(ebp); |
| 93 __ ret((parameter_count_ + 1) * kPointerSize); |
| 94 } |
| 95 |
| 96 |
| 97 void ReturnInstr::Compile(MacroAssembler* masm) { |
| 98 Comment cmnt(masm, "[ ReturnInstr"); |
| 99 value_->ToRegister(masm, eax); |
| 100 } |
| 101 |
| 102 |
| 103 void Constant::ToRegister(MacroAssembler* masm, Register reg) { |
| 104 __ mov(reg, Immediate(handle_)); |
| 105 } |
| 106 |
| 107 #undef __ |
| 108 |
| 109 } } // namespace v8::internal |
OLD | NEW |