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

Side by Side Diff: src/virtual-frame-arm.cc

Issue 10829: Finish porting jump target changes to the ARM platform. The v8 test... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 12 years, 1 month 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-arm.h ('k') | src/virtual-frame-arm-inl.h » ('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 20 matching lines...) Expand all
31 #include "codegen-inl.h" 31 #include "codegen-inl.h"
32 #include "virtual-frame.h" 32 #include "virtual-frame.h"
33 33
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 ASSERT(cgen->scope() != NULL); 42 : masm_(cgen->masm()),
43 43 elements_(0),
44 masm_ = cgen->masm(); 44 virtual_stack_pointer_(-1),
45 frame_local_count_ = cgen->scope()->num_stack_slots(); 45 virtual_frame_pointer_(-1),
46 parameter_count_ = cgen->scope()->num_parameters(); 46 parameter_count_(cgen->scope()->num_parameters()),
47 local_count_(0) {
48 // The virtual frame contains a receiver and the parameters (all in
49 // memory) when it is created.
50 Adjust(parameter_count_ + 1);
47 } 51 }
48 52
49 53
50 VirtualFrame::VirtualFrame(VirtualFrame* original) { 54 VirtualFrame::VirtualFrame(VirtualFrame* original)
51 ASSERT(original == NULL); 55 : masm_(original->masm_),
56 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_),
60 local_count_(original->local_count_) {
61 // Copy all the elements.
62 for (int i = 0; i <= virtual_stack_pointer_; i++) {
63 elements_.Add(original->elements_[i]);
64 }
65 }
66
67
68 void VirtualFrame::Adjust(int count) {
69 ASSERT(count >= 0);
70 for (int i = 0; i < count; i++) {
71 AddElement(Element());
72 }
73 }
74
75
76 void VirtualFrame::Forget(int count) {
77 ASSERT(count >= 0);
78 ASSERT(virtual_stack_pointer_ >= count);
79 for (int i = 0; i < count; i++) {
80 RemoveElement();
81 }
52 } 82 }
53 83
54 84
55 void VirtualFrame::MergeTo(VirtualFrame* expected) { 85 void VirtualFrame::MergeTo(VirtualFrame* expected) {
56 ASSERT(expected == NULL); 86 ASSERT(masm_ == expected->masm_);
87 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_);
91 ASSERT(local_count_ == expected->local_count_);
92 for (int i = 0; i <= virtual_stack_pointer_; i++) {
93 ASSERT(elements_[i].matches(expected->elements_[i]));
94 }
57 } 95 }
58 96
59 97
60 void VirtualFrame::Enter() { 98 void VirtualFrame::Enter() {
61 Comment cmnt(masm_, "[ Enter JS frame"); 99 Comment cmnt(masm_, "[ Enter JS frame");
62 #ifdef DEBUG 100 #ifdef DEBUG
63 { Label done, fail; 101 { Label done, fail;
64 __ tst(r1, Operand(kSmiTagMask)); 102 __ tst(r1, Operand(kSmiTagMask));
65 __ b(eq, &fail); 103 __ b(eq, &fail);
66 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); 104 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset));
67 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); 105 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset));
68 __ cmp(r2, Operand(JS_FUNCTION_TYPE)); 106 __ cmp(r2, Operand(JS_FUNCTION_TYPE));
69 __ b(eq, &done); 107 __ b(eq, &done);
70 __ bind(&fail); 108 __ bind(&fail);
71 __ stop("CodeGenerator::EnterJSFrame - r1 not a function"); 109 __ stop("CodeGenerator::EnterJSFrame - r1 not a function");
72 __ bind(&done); 110 __ bind(&done);
73 } 111 }
74 #endif // DEBUG 112 #endif // DEBUG
75 113
114 Adjust(4);
76 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); 115 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit());
77 // Adjust FP to point to saved FP. 116 // Adjust FP to point to saved FP.
117 virtual_frame_pointer_ = virtual_stack_pointer_ - 1;
78 __ add(fp, sp, Operand(2 * kPointerSize)); 118 __ add(fp, sp, Operand(2 * kPointerSize));
79 } 119 }
80 120
81 121
82 void VirtualFrame::Exit() { 122 void VirtualFrame::Exit() {
83 Comment cmnt(masm_, "[ Exit JS frame"); 123 Comment cmnt(masm_, "[ Exit JS frame");
84 // Drop the execution stack down to the frame pointer and restore the caller 124 // Drop the execution stack down to the frame pointer and restore the caller
85 // frame pointer and return address. 125 // frame pointer and return address.
86 __ mov(sp, fp); 126 __ mov(sp, fp);
87 __ ldm(ia_w, sp, fp.bit() | lr.bit()); 127 __ ldm(ia_w, sp, fp.bit() | lr.bit());
88 } 128 }
89 129
90 130
91 void VirtualFrame::AllocateLocals() { 131 void VirtualFrame::AllocateStackSlots(int count) {
92 if (frame_local_count_ > 0) { 132 ASSERT(height() == 0);
133 local_count_ = count;
134 Adjust(count);
135 if (count > 0) {
93 Comment cmnt(masm_, "[ Allocate space for locals"); 136 Comment cmnt(masm_, "[ Allocate space for locals");
94 // Initialize stack slots with 'undefined' value. 137 // Initialize stack slots with 'undefined' value.
95 __ mov(ip, Operand(Factory::undefined_value())); 138 __ mov(ip, Operand(Factory::undefined_value()));
96 for (int i = 0; i < frame_local_count_; i++) { 139 for (int i = 0; i < count; i++) {
97 __ push(ip); 140 __ push(ip);
98 } 141 }
99 } 142 }
100 } 143 }
101 144
145
146 void VirtualFrame::PushTryHandler(HandlerType type) {
147 // Grow the expression stack by handler size less one (the return address
148 // is already pushed by a call instruction).
149 Adjust(kHandlerSize - 1);
150 __ PushTryHandler(IN_JAVASCRIPT, type);
151 }
152
153
154 void VirtualFrame::CallStub(CodeStub* stub, int frame_arg_count) {
155 ASSERT(height() >= frame_arg_count);
156 Forget(frame_arg_count);
157 __ CallStub(stub);
158 }
159
160
161 void VirtualFrame::CallRuntime(Runtime::Function* f, int frame_arg_count) {
162 ASSERT(height() >= frame_arg_count);
163 Forget(frame_arg_count);
164 __ CallRuntime(f, frame_arg_count);
165 }
166
167
168 void VirtualFrame::CallRuntime(Runtime::FunctionId id, int frame_arg_count) {
169 ASSERT(height() >= frame_arg_count);
170 Forget(frame_arg_count);
171 __ CallRuntime(id, frame_arg_count);
172 }
173
174
175 void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id,
176 InvokeJSFlags flags,
177 int frame_arg_count) {
178 ASSERT(height() >= frame_arg_count);
179 Forget(frame_arg_count);
180 __ InvokeBuiltin(id, flags);
181 }
182
183
184 void VirtualFrame::CallCodeObject(Handle<Code> code,
185 RelocInfo::Mode rmode,
186 int frame_arg_count) {
187 ASSERT(height() >= frame_arg_count);
188 Forget(frame_arg_count);
189 __ Call(code, rmode);
190 }
191
192
193 void VirtualFrame::Drop(int count) {
194 ASSERT(height() >= count);
195 Forget(count);
196 if (count > 0) {
197 __ add(sp, sp, Operand(count * kPointerSize));
198 }
199 }
200
201
202 void VirtualFrame::Drop() { Drop(1); }
203
204
205 void VirtualFrame::Pop(Register reg) {
206 Forget(1);
207 __ pop(reg);
208 }
209
210
211 void VirtualFrame::Push(Register reg) {
212 Adjust(1);
213 __ push(reg);
214 }
215
216
102 #undef __ 217 #undef __
103 218
104 } } // namespace v8::internal 219 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/virtual-frame-arm.h ('k') | src/virtual-frame-arm-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698