Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: src/virtual-frame-inl.h

Issue 1164002: Split the virtual frame into heavy and light versions.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/virtual-frame-heavy-inl.h ('k') | src/virtual-frame-light.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_VIRTUAL_FRAME_INL_H_ 28 #ifndef V8_VIRTUAL_FRAME_INL_H_
29 #define V8_VIRTUAL_FRAME_INL_H_ 29 #define V8_VIRTUAL_FRAME_INL_H_
30 30
31 #include "virtual-frame.h" 31 #include "virtual-frame.h"
32 32
33 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64
34 #include "virtual-frame-heavy-inl.h"
35 #else
36 #include "virtual-frame-light-inl.h"
37 #endif
38
39
33 namespace v8 { 40 namespace v8 {
34 namespace internal { 41 namespace internal {
35 42
36
37 // On entry to a function, the virtual frame already contains the receiver,
38 // the parameters, and a return address. All frame elements are in memory.
39 VirtualFrame::VirtualFrame()
40 : elements_(parameter_count() + local_count() + kPreallocatedElements),
41 stack_pointer_(parameter_count() + 1) { // 0-based index of TOS.
42 for (int i = 0; i <= stack_pointer_; i++) {
43 elements_.Add(FrameElement::MemoryElement(NumberInfo::Unknown()));
44 }
45 for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
46 register_locations_[i] = kIllegalIndex;
47 }
48 }
49
50
51 // When cloned, a frame is a deep copy of the original.
52 VirtualFrame::VirtualFrame(VirtualFrame* original)
53 : elements_(original->element_count()),
54 stack_pointer_(original->stack_pointer_) {
55 elements_.AddAll(original->elements_);
56 // Copy register locations from original.
57 memcpy(&register_locations_,
58 original->register_locations_,
59 sizeof(register_locations_));
60 }
61
62
63 void VirtualFrame::PushFrameSlotAt(int index) {
64 elements_.Add(CopyElementAt(index));
65 }
66
67
68 void VirtualFrame::Push(Register reg, NumberInfo info) {
69 if (is_used(reg)) {
70 int index = register_location(reg);
71 FrameElement element = CopyElementAt(index, info);
72 elements_.Add(element);
73 } else {
74 Use(reg, element_count());
75 FrameElement element =
76 FrameElement::RegisterElement(reg, FrameElement::NOT_SYNCED, info);
77 elements_.Add(element);
78 }
79 }
80
81
82 void VirtualFrame::Push(Handle<Object> value) {
83 FrameElement element =
84 FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED);
85 elements_.Add(element);
86 }
87
88
89 void VirtualFrame::Push(Smi* value) { 43 void VirtualFrame::Push(Smi* value) {
90 Push(Handle<Object> (value)); 44 Push(Handle<Object> (value));
91 } 45 }
92 46
93 47
94 void VirtualFrame::Nip(int num_dropped) { 48 void VirtualFrame::Nip(int num_dropped) {
95 ASSERT(num_dropped >= 0); 49 ASSERT(num_dropped >= 0);
96 if (num_dropped == 0) return; 50 if (num_dropped == 0) return;
97 Result tos = Pop(); 51 Result tos = Pop();
98 if (num_dropped > 1) { 52 if (num_dropped > 1) {
99 Drop(num_dropped - 1); 53 Drop(num_dropped - 1);
100 } 54 }
101 SetElementAt(0, &tos); 55 SetElementAt(0, &tos);
102 } 56 }
103 57
104 58
105 bool VirtualFrame::Equals(VirtualFrame* other) {
106 #ifdef DEBUG
107 for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
108 if (register_location(i) != other->register_location(i)) {
109 return false;
110 }
111 }
112 if (element_count() != other->element_count()) return false;
113 #endif
114 if (stack_pointer_ != other->stack_pointer_) return false;
115 for (int i = 0; i < element_count(); i++) {
116 if (!elements_[i].Equals(other->elements_[i])) return false;
117 }
118
119 return true;
120 }
121
122
123 void VirtualFrame::SetTypeForLocalAt(int index, NumberInfo info) {
124 elements_[local0_index() + index].set_number_info(info);
125 }
126
127
128 void VirtualFrame::SetTypeForParamAt(int index, NumberInfo info) { 59 void VirtualFrame::SetTypeForParamAt(int index, NumberInfo info) {
129 elements_[param0_index() + index].set_number_info(info); 60 elements_[param0_index() + index].set_number_info(info);
130 } 61 }
131 62
132 63
133 } } // namespace v8::internal 64 } } // namespace v8::internal
134 65
135 #endif // V8_VIRTUAL_FRAME_INL_H_ 66 #endif // V8_VIRTUAL_FRAME_INL_H_
OLDNEW
« no previous file with comments | « src/virtual-frame-heavy-inl.h ('k') | src/virtual-frame-light.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698