| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 23 matching lines...) Expand all Loading... |
| 34 namespace v8 { namespace internal { | 34 namespace v8 { namespace internal { |
| 35 | 35 |
| 36 // ------------------------------------------------------------------------- | 36 // ------------------------------------------------------------------------- |
| 37 // VirtualFrame implementation. | 37 // VirtualFrame implementation. |
| 38 | 38 |
| 39 #define __ masm_-> | 39 #define __ masm_-> |
| 40 | 40 |
| 41 VirtualFrame::VirtualFrame(CodeGenerator* cgen) | 41 VirtualFrame::VirtualFrame(CodeGenerator* cgen) |
| 42 : masm_(cgen->masm()), | 42 : masm_(cgen->masm()), |
| 43 elements_(0), | 43 elements_(0), |
| 44 virtual_stack_pointer_(-1), | |
| 45 virtual_frame_pointer_(-1), | |
| 46 parameter_count_(cgen->scope()->num_parameters()), | 44 parameter_count_(cgen->scope()->num_parameters()), |
| 47 local_count_(0) { | 45 local_count_(0), |
| 46 frame_pointer_(-1) { |
| 48 // The virtual frame contains a receiver, the parameters, and a return | 47 // The virtual frame contains a receiver, the parameters, and a return |
| 49 // address (all in memory) when it is created. | 48 // address (all in memory) when it is created. |
| 50 Adjust(parameter_count_ + 2); | 49 Adjust(parameter_count_ + 2); |
| 51 } | 50 } |
| 52 | 51 |
| 53 | 52 |
| 54 VirtualFrame::VirtualFrame(VirtualFrame* original) | 53 VirtualFrame::VirtualFrame(VirtualFrame* original) |
| 55 : masm_(original->masm_), | 54 : masm_(original->masm_), |
| 56 elements_(original->elements_.length()), | 55 elements_(original->elements_.length()), |
| 57 virtual_stack_pointer_(original->virtual_stack_pointer_), | |
| 58 virtual_frame_pointer_(original->virtual_frame_pointer_), | |
| 59 parameter_count_(original->parameter_count_), | 56 parameter_count_(original->parameter_count_), |
| 60 local_count_(original->local_count_) { | 57 local_count_(original->local_count_), |
| 58 frame_pointer_(original->frame_pointer_) { |
| 61 // Copy all the elements. | 59 // Copy all the elements. |
| 62 for (int i = 0; i <= virtual_stack_pointer_; i++) { | 60 for (int i = 0; i < original->elements_.length(); i++) { |
| 63 elements_.Add(original->elements_[i]); | 61 elements_.Add(original->elements_[i]); |
| 64 } | 62 } |
| 65 } | 63 } |
| 66 | 64 |
| 67 | 65 |
| 68 void VirtualFrame::Adjust(int count) { | 66 void VirtualFrame::Adjust(int count) { |
| 69 ASSERT(count >= 0); | 67 ASSERT(count >= 0); |
| 70 for (int i = 0; i < count; i++) { | 68 for (int i = 0; i < count; i++) { |
| 71 AddElement(Element()); | 69 elements_.Add(Element()); |
| 72 } | 70 } |
| 73 } | 71 } |
| 74 | 72 |
| 75 | 73 |
| 76 void VirtualFrame::Forget(int count) { | 74 void VirtualFrame::Forget(int count) { |
| 77 ASSERT(count >= 0); | 75 ASSERT(count >= 0); |
| 78 ASSERT(virtual_stack_pointer_ >= count); | 76 ASSERT(elements_.length() >= count); |
| 79 for (int i = 0; i < count; i++) { | 77 for (int i = 0; i < count; i++) { |
| 80 RemoveElement(); | 78 elements_.RemoveLast(); |
| 81 } | 79 } |
| 82 } | 80 } |
| 83 | 81 |
| 84 | 82 |
| 85 void VirtualFrame::MergeTo(VirtualFrame* expected) { | 83 void VirtualFrame::MergeTo(VirtualFrame* expected) { |
| 86 ASSERT(masm_ == expected->masm_); | 84 ASSERT(masm_ == expected->masm_); |
| 87 ASSERT(elements_.length() == expected->elements_.length()); | 85 ASSERT(elements_.length() == expected->elements_.length()); |
| 88 ASSERT(virtual_frame_pointer_ == expected->virtual_frame_pointer_); | |
| 89 ASSERT(virtual_stack_pointer_ == expected->virtual_stack_pointer_); | |
| 90 ASSERT(parameter_count_ == expected->parameter_count_); | 86 ASSERT(parameter_count_ == expected->parameter_count_); |
| 91 ASSERT(local_count_ == expected->local_count_); | 87 ASSERT(local_count_ == expected->local_count_); |
| 92 for (int i = 0; i <= virtual_stack_pointer_; i++) { | 88 ASSERT(frame_pointer_ == expected->frame_pointer_); |
| 89 for (int i = 0; i < elements_.length(); i++) { |
| 93 ASSERT(elements_[i].matches(expected->elements_[i])); | 90 ASSERT(elements_[i].matches(expected->elements_[i])); |
| 94 } | 91 } |
| 95 } | 92 } |
| 96 | 93 |
| 97 | 94 |
| 98 void VirtualFrame::Enter() { | 95 void VirtualFrame::Enter() { |
| 99 Comment cmnt(masm_, "[ Enter JS frame"); | 96 Comment cmnt(masm_, "[ Enter JS frame"); |
| 100 Adjust(1); | 97 Adjust(1); |
| 101 __ push(ebp); | 98 __ push(ebp); |
| 102 | 99 |
| 103 virtual_frame_pointer_ = virtual_stack_pointer_; | 100 frame_pointer_ = elements_.length() - 1; |
| 104 __ mov(ebp, Operand(esp)); | 101 __ mov(ebp, Operand(esp)); |
| 105 | 102 |
| 106 // Store the context and the function in the frame. | 103 // Store the context and the function in the frame. |
| 107 Adjust(2); | 104 Adjust(2); |
| 108 __ push(esi); | 105 __ push(esi); |
| 109 __ push(edi); | 106 __ push(edi); |
| 110 | 107 |
| 111 // Clear the function slot when generating debug code. | 108 // Clear the function slot when generating debug code. |
| 112 if (FLAG_debug_code) { | 109 if (FLAG_debug_code) { |
| 113 __ Set(edi, Immediate(reinterpret_cast<int>(kZapValue))); | 110 __ Set(edi, Immediate(reinterpret_cast<int>(kZapValue))); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 229 |
| 233 | 230 |
| 234 void VirtualFrame::Push(Immediate immediate) { | 231 void VirtualFrame::Push(Immediate immediate) { |
| 235 Adjust(1); | 232 Adjust(1); |
| 236 __ push(immediate); | 233 __ push(immediate); |
| 237 } | 234 } |
| 238 | 235 |
| 239 #undef __ | 236 #undef __ |
| 240 | 237 |
| 241 } } // namespace v8::internal | 238 } } // namespace v8::internal |
| OLD | NEW |