OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // |
| 3 // Copyright IBM Corp. 2012, 2013. All rights reserved. |
| 4 // |
2 // Use of this source code is governed by a BSD-style license that can be | 5 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 6 // found in the LICENSE file. |
4 | 7 |
5 #include "src/v8.h" | 8 #include "src/v8.h" |
6 | 9 |
7 #if V8_TARGET_ARCH_ARM | 10 #if V8_TARGET_ARCH_PPC |
8 | 11 |
9 #include "src/code-stubs.h" | 12 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 13 #include "src/codegen.h" |
11 #include "src/compiler.h" | 14 #include "src/compiler.h" |
12 #include "src/debug.h" | 15 #include "src/debug.h" |
13 #include "src/full-codegen.h" | 16 #include "src/full-codegen.h" |
14 #include "src/isolate-inl.h" | 17 #include "src/isolate-inl.h" |
15 #include "src/parser.h" | 18 #include "src/parser.h" |
16 #include "src/scopes.h" | 19 #include "src/scopes.h" |
17 #include "src/stub-cache.h" | 20 #include "src/stub-cache.h" |
18 | 21 |
19 #include "src/arm/code-stubs-arm.h" | 22 #include "src/ppc/code-stubs-ppc.h" |
20 #include "src/arm/macro-assembler-arm.h" | 23 #include "src/ppc/macro-assembler-ppc.h" |
21 | 24 |
22 namespace v8 { | 25 namespace v8 { |
23 namespace internal { | 26 namespace internal { |
24 | 27 |
25 #define __ ACCESS_MASM(masm_) | 28 #define __ ACCESS_MASM(masm_) |
26 | 29 |
27 | |
28 // A patch site is a location in the code which it is possible to patch. This | 30 // A patch site is a location in the code which it is possible to patch. This |
29 // class has a number of methods to emit the code which is patchable and the | 31 // class has a number of methods to emit the code which is patchable and the |
30 // method EmitPatchInfo to record a marker back to the patchable code. This | 32 // method EmitPatchInfo to record a marker back to the patchable code. This |
31 // marker is a cmp rx, #yyy instruction, and x * 0x00000fff + yyy (raw 12 bit | 33 // marker is a cmpi rx, #yyy instruction, and x * 0x0000ffff + yyy (raw 16 bit |
32 // immediate value is used) is the delta from the pc to the first instruction of | 34 // immediate value is used) is the delta from the pc to the first instruction of |
33 // the patchable code. | 35 // the patchable code. |
| 36 // See PatchInlinedSmiCode in ic-ppc.cc for the code that patches it |
34 class JumpPatchSite BASE_EMBEDDED { | 37 class JumpPatchSite BASE_EMBEDDED { |
35 public: | 38 public: |
36 explicit JumpPatchSite(MacroAssembler* masm) : masm_(masm) { | 39 explicit JumpPatchSite(MacroAssembler* masm) : masm_(masm) { |
37 #ifdef DEBUG | 40 #ifdef DEBUG |
38 info_emitted_ = false; | 41 info_emitted_ = false; |
39 #endif | 42 #endif |
40 } | 43 } |
41 | 44 |
42 ~JumpPatchSite() { | 45 ~JumpPatchSite() { DCHECK(patch_site_.is_bound() == info_emitted_); } |
43 DCHECK(patch_site_.is_bound() == info_emitted_); | |
44 } | |
45 | 46 |
46 // When initially emitting this ensure that a jump is always generated to skip | 47 // When initially emitting this ensure that a jump is always generated to skip |
47 // the inlined smi code. | 48 // the inlined smi code. |
48 void EmitJumpIfNotSmi(Register reg, Label* target) { | 49 void EmitJumpIfNotSmi(Register reg, Label* target) { |
49 DCHECK(!patch_site_.is_bound() && !info_emitted_); | 50 DCHECK(!patch_site_.is_bound() && !info_emitted_); |
50 Assembler::BlockConstPoolScope block_const_pool(masm_); | 51 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); |
51 __ bind(&patch_site_); | 52 __ bind(&patch_site_); |
52 __ cmp(reg, Operand(reg)); | 53 __ cmp(reg, reg, cr0); |
53 __ b(eq, target); // Always taken before patched. | 54 __ beq(target, cr0); // Always taken before patched. |
54 } | 55 } |
55 | 56 |
56 // When initially emitting this ensure that a jump is never generated to skip | 57 // When initially emitting this ensure that a jump is never generated to skip |
57 // the inlined smi code. | 58 // the inlined smi code. |
58 void EmitJumpIfSmi(Register reg, Label* target) { | 59 void EmitJumpIfSmi(Register reg, Label* target) { |
| 60 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); |
59 DCHECK(!patch_site_.is_bound() && !info_emitted_); | 61 DCHECK(!patch_site_.is_bound() && !info_emitted_); |
60 Assembler::BlockConstPoolScope block_const_pool(masm_); | |
61 __ bind(&patch_site_); | 62 __ bind(&patch_site_); |
62 __ cmp(reg, Operand(reg)); | 63 __ cmp(reg, reg, cr0); |
63 __ b(ne, target); // Never taken before patched. | 64 __ bne(target, cr0); // Never taken before patched. |
64 } | 65 } |
65 | 66 |
66 void EmitPatchInfo() { | 67 void EmitPatchInfo() { |
67 // Block literal pool emission whilst recording patch site information. | |
68 Assembler::BlockConstPoolScope block_const_pool(masm_); | |
69 if (patch_site_.is_bound()) { | 68 if (patch_site_.is_bound()) { |
70 int delta_to_patch_site = masm_->InstructionsGeneratedSince(&patch_site_); | 69 int delta_to_patch_site = masm_->InstructionsGeneratedSince(&patch_site_); |
71 Register reg; | 70 Register reg; |
72 reg.set_code(delta_to_patch_site / kOff12Mask); | 71 // I believe this is using reg as the high bits of of the offset |
73 __ cmp_raw_immediate(reg, delta_to_patch_site % kOff12Mask); | 72 reg.set_code(delta_to_patch_site / kOff16Mask); |
| 73 __ cmpi(reg, Operand(delta_to_patch_site % kOff16Mask)); |
74 #ifdef DEBUG | 74 #ifdef DEBUG |
75 info_emitted_ = true; | 75 info_emitted_ = true; |
76 #endif | 76 #endif |
77 } else { | 77 } else { |
78 __ nop(); // Signals no inlined code. | 78 __ nop(); // Signals no inlined code. |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 private: | 82 private: |
83 MacroAssembler* masm_; | 83 MacroAssembler* masm_; |
84 Label patch_site_; | 84 Label patch_site_; |
85 #ifdef DEBUG | 85 #ifdef DEBUG |
86 bool info_emitted_; | 86 bool info_emitted_; |
87 #endif | 87 #endif |
88 }; | 88 }; |
89 | 89 |
90 | 90 |
91 // Generate code for a JS function. On entry to the function the receiver | 91 // Generate code for a JS function. On entry to the function the receiver |
92 // and arguments have been pushed on the stack left to right. The actual | 92 // and arguments have been pushed on the stack left to right. The actual |
93 // argument count matches the formal parameter count expected by the | 93 // argument count matches the formal parameter count expected by the |
94 // function. | 94 // function. |
95 // | 95 // |
96 // The live registers are: | 96 // The live registers are: |
97 // o r1: the JS function object being called (i.e., ourselves) | 97 // o r4: the JS function object being called (i.e., ourselves) |
98 // o cp: our context | 98 // o cp: our context |
99 // o pp: our caller's constant pool pointer (if FLAG_enable_ool_constant_pool) | 99 // o fp: our caller's frame pointer (aka r31) |
100 // o fp: our caller's frame pointer | |
101 // o sp: stack pointer | 100 // o sp: stack pointer |
102 // o lr: return address | 101 // o lr: return address (bogus.. PPC has no lr reg) |
103 // | 102 // |
104 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 103 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
105 // frames-arm.h for its layout. | 104 // frames-ppc.h for its layout. |
106 void FullCodeGenerator::Generate() { | 105 void FullCodeGenerator::Generate() { |
107 CompilationInfo* info = info_; | 106 CompilationInfo* info = info_; |
108 handler_table_ = | 107 handler_table_ = |
109 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); | 108 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); |
110 | 109 |
111 profiling_counter_ = isolate()->factory()->NewCell( | 110 profiling_counter_ = isolate()->factory()->NewCell( |
112 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); | 111 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); |
113 SetFunctionPosition(function()); | 112 SetFunctionPosition(function()); |
114 Comment cmnt(masm_, "[ function compiled by full code generator"); | 113 Comment cmnt(masm_, "[ function compiled by full code generator"); |
115 | 114 |
116 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 115 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
117 | 116 |
118 #ifdef DEBUG | 117 #ifdef DEBUG |
119 if (strlen(FLAG_stop_at) > 0 && | 118 if (strlen(FLAG_stop_at) > 0 && |
120 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 119 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
121 __ stop("stop-at"); | 120 __ stop("stop-at"); |
122 } | 121 } |
123 #endif | 122 #endif |
124 | 123 |
125 // Sloppy mode functions and builtins need to replace the receiver with the | 124 // Sloppy mode functions and builtins need to replace the receiver with the |
126 // global proxy when called as functions (without an explicit receiver | 125 // global proxy when called as functions (without an explicit receiver |
127 // object). | 126 // object). |
128 if (info->strict_mode() == SLOPPY && !info->is_native()) { | 127 if (info->strict_mode() == SLOPPY && !info->is_native()) { |
129 Label ok; | 128 Label ok; |
130 int receiver_offset = info->scope()->num_parameters() * kPointerSize; | 129 int receiver_offset = info->scope()->num_parameters() * kPointerSize; |
131 __ ldr(r2, MemOperand(sp, receiver_offset)); | 130 __ LoadP(r5, MemOperand(sp, receiver_offset), r0); |
132 __ CompareRoot(r2, Heap::kUndefinedValueRootIndex); | 131 __ CompareRoot(r5, Heap::kUndefinedValueRootIndex); |
133 __ b(ne, &ok); | 132 __ bne(&ok); |
134 | 133 |
135 __ ldr(r2, GlobalObjectOperand()); | 134 __ LoadP(r5, GlobalObjectOperand()); |
136 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalProxyOffset)); | 135 __ LoadP(r5, FieldMemOperand(r5, GlobalObject::kGlobalProxyOffset)); |
137 | 136 |
138 __ str(r2, MemOperand(sp, receiver_offset)); | 137 __ StoreP(r5, MemOperand(sp, receiver_offset), r0); |
139 | 138 |
140 __ bind(&ok); | 139 __ bind(&ok); |
141 } | 140 } |
142 | 141 |
143 // Open a frame scope to indicate that there is a frame on the stack. The | 142 // Open a frame scope to indicate that there is a frame on the stack. The |
144 // MANUAL indicates that the scope shouldn't actually generate code to set up | 143 // MANUAL indicates that the scope shouldn't actually generate code to set up |
145 // the frame (that is done below). | 144 // the frame (that is done below). |
146 FrameScope frame_scope(masm_, StackFrame::MANUAL); | 145 FrameScope frame_scope(masm_, StackFrame::MANUAL); |
147 | 146 |
148 info->set_prologue_offset(masm_->pc_offset()); | 147 info->set_prologue_offset(masm_->pc_offset()); |
149 __ Prologue(info->IsCodePreAgingActive()); | 148 __ Prologue(info->IsCodePreAgingActive()); |
150 info->AddNoFrameRange(0, masm_->pc_offset()); | 149 info->AddNoFrameRange(0, masm_->pc_offset()); |
151 | 150 |
152 { Comment cmnt(masm_, "[ Allocate locals"); | 151 { |
| 152 Comment cmnt(masm_, "[ Allocate locals"); |
153 int locals_count = info->scope()->num_stack_slots(); | 153 int locals_count = info->scope()->num_stack_slots(); |
154 // Generators allocate locals, if any, in context slots. | 154 // Generators allocate locals, if any, in context slots. |
155 DCHECK(!info->function()->is_generator() || locals_count == 0); | 155 DCHECK(!info->function()->is_generator() || locals_count == 0); |
156 if (locals_count > 0) { | 156 if (locals_count > 0) { |
157 if (locals_count >= 128) { | 157 if (locals_count >= 128) { |
158 Label ok; | 158 Label ok; |
159 __ sub(r9, sp, Operand(locals_count * kPointerSize)); | 159 __ Add(ip, sp, -(locals_count * kPointerSize), r0); |
160 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); | 160 __ LoadRoot(r5, Heap::kRealStackLimitRootIndex); |
161 __ cmp(r9, Operand(r2)); | 161 __ cmpl(ip, r5); |
162 __ b(hs, &ok); | 162 __ bc_short(ge, &ok); |
163 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); | 163 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); |
164 __ bind(&ok); | 164 __ bind(&ok); |
165 } | 165 } |
166 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); | 166 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
167 int kMaxPushes = FLAG_optimize_for_size ? 4 : 32; | 167 int kMaxPushes = FLAG_optimize_for_size ? 4 : 32; |
168 if (locals_count >= kMaxPushes) { | 168 if (locals_count >= kMaxPushes) { |
169 int loop_iterations = locals_count / kMaxPushes; | 169 int loop_iterations = locals_count / kMaxPushes; |
170 __ mov(r2, Operand(loop_iterations)); | 170 __ mov(r5, Operand(loop_iterations)); |
| 171 __ mtctr(r5); |
171 Label loop_header; | 172 Label loop_header; |
172 __ bind(&loop_header); | 173 __ bind(&loop_header); |
173 // Do pushes. | 174 // Do pushes. |
174 for (int i = 0; i < kMaxPushes; i++) { | 175 for (int i = 0; i < kMaxPushes; i++) { |
175 __ push(r9); | 176 __ push(ip); |
176 } | 177 } |
177 // Continue loop if not done. | 178 // Continue loop if not done. |
178 __ sub(r2, r2, Operand(1), SetCC); | 179 __ bdnz(&loop_header); |
179 __ b(&loop_header, ne); | |
180 } | 180 } |
181 int remaining = locals_count % kMaxPushes; | 181 int remaining = locals_count % kMaxPushes; |
182 // Emit the remaining pushes. | 182 // Emit the remaining pushes. |
183 for (int i = 0; i < remaining; i++) { | 183 for (int i = 0; i < remaining; i++) { |
184 __ push(r9); | 184 __ push(ip); |
185 } | 185 } |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 bool function_in_register = true; | 189 bool function_in_register = true; |
190 | 190 |
191 // Possibly allocate a local context. | 191 // Possibly allocate a local context. |
192 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 192 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
193 if (heap_slots > 0) { | 193 if (heap_slots > 0) { |
194 // Argument to NewContext is the function, which is still in r1. | 194 // Argument to NewContext is the function, which is still in r4. |
195 Comment cmnt(masm_, "[ Allocate context"); | 195 Comment cmnt(masm_, "[ Allocate context"); |
196 bool need_write_barrier = true; | 196 bool need_write_barrier = true; |
197 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { | 197 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { |
198 __ push(r1); | 198 __ push(r4); |
199 __ Push(info->scope()->GetScopeInfo()); | 199 __ Push(info->scope()->GetScopeInfo()); |
200 __ CallRuntime(Runtime::kNewGlobalContext, 2); | 200 __ CallRuntime(Runtime::kNewGlobalContext, 2); |
201 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 201 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
202 FastNewContextStub stub(isolate(), heap_slots); | 202 FastNewContextStub stub(isolate(), heap_slots); |
203 __ CallStub(&stub); | 203 __ CallStub(&stub); |
204 // Result of FastNewContextStub is always in new space. | 204 // Result of FastNewContextStub is always in new space. |
205 need_write_barrier = false; | 205 need_write_barrier = false; |
206 } else { | 206 } else { |
207 __ push(r1); | 207 __ push(r4); |
208 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 208 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
209 } | 209 } |
210 function_in_register = false; | 210 function_in_register = false; |
211 // Context is returned in r0. It replaces the context passed to us. | 211 // Context is returned in r3. It replaces the context passed to us. |
212 // It's saved in the stack and kept live in cp. | 212 // It's saved in the stack and kept live in cp. |
213 __ mov(cp, r0); | 213 __ mr(cp, r3); |
214 __ str(r0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 214 __ StoreP(r3, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
215 // Copy any necessary parameters into the context. | 215 // Copy any necessary parameters into the context. |
216 int num_parameters = info->scope()->num_parameters(); | 216 int num_parameters = info->scope()->num_parameters(); |
217 for (int i = 0; i < num_parameters; i++) { | 217 for (int i = 0; i < num_parameters; i++) { |
218 Variable* var = scope()->parameter(i); | 218 Variable* var = scope()->parameter(i); |
219 if (var->IsContextSlot()) { | 219 if (var->IsContextSlot()) { |
220 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 220 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
221 (num_parameters - 1 - i) * kPointerSize; | 221 (num_parameters - 1 - i) * kPointerSize; |
222 // Load parameter from stack. | 222 // Load parameter from stack. |
223 __ ldr(r0, MemOperand(fp, parameter_offset)); | 223 __ LoadP(r3, MemOperand(fp, parameter_offset), r0); |
224 // Store it in the context. | 224 // Store it in the context. |
225 MemOperand target = ContextOperand(cp, var->index()); | 225 MemOperand target = ContextOperand(cp, var->index()); |
226 __ str(r0, target); | 226 __ StoreP(r3, target, r0); |
227 | 227 |
228 // Update the write barrier. | 228 // Update the write barrier. |
229 if (need_write_barrier) { | 229 if (need_write_barrier) { |
230 __ RecordWriteContextSlot( | 230 __ RecordWriteContextSlot(cp, target.offset(), r3, r6, |
231 cp, target.offset(), r0, r3, kLRHasBeenSaved, kDontSaveFPRegs); | 231 kLRHasBeenSaved, kDontSaveFPRegs); |
232 } else if (FLAG_debug_code) { | 232 } else if (FLAG_debug_code) { |
233 Label done; | 233 Label done; |
234 __ JumpIfInNewSpace(cp, r0, &done); | 234 __ JumpIfInNewSpace(cp, r3, &done); |
235 __ Abort(kExpectedNewSpaceObject); | 235 __ Abort(kExpectedNewSpaceObject); |
236 __ bind(&done); | 236 __ bind(&done); |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 Variable* arguments = scope()->arguments(); | 242 Variable* arguments = scope()->arguments(); |
243 if (arguments != NULL) { | 243 if (arguments != NULL) { |
244 // Function uses arguments object. | 244 // Function uses arguments object. |
245 Comment cmnt(masm_, "[ Allocate arguments object"); | 245 Comment cmnt(masm_, "[ Allocate arguments object"); |
246 if (!function_in_register) { | 246 if (!function_in_register) { |
247 // Load this again, if it's used by the local context below. | 247 // Load this again, if it's used by the local context below. |
248 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 248 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
249 } else { | 249 } else { |
250 __ mov(r3, r1); | 250 __ mr(r6, r4); |
251 } | 251 } |
252 // Receiver is just before the parameters on the caller's stack. | 252 // Receiver is just before the parameters on the caller's stack. |
253 int num_parameters = info->scope()->num_parameters(); | 253 int num_parameters = info->scope()->num_parameters(); |
254 int offset = num_parameters * kPointerSize; | 254 int offset = num_parameters * kPointerSize; |
255 __ add(r2, fp, | 255 __ addi(r5, fp, Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
256 Operand(StandardFrameConstants::kCallerSPOffset + offset)); | 256 __ LoadSmiLiteral(r4, Smi::FromInt(num_parameters)); |
257 __ mov(r1, Operand(Smi::FromInt(num_parameters))); | 257 __ Push(r6, r5, r4); |
258 __ Push(r3, r2, r1); | |
259 | 258 |
260 // Arguments to ArgumentsAccessStub: | 259 // Arguments to ArgumentsAccessStub: |
261 // function, receiver address, parameter count. | 260 // function, receiver address, parameter count. |
262 // The stub will rewrite receiever and parameter count if the previous | 261 // The stub will rewrite receiever and parameter count if the previous |
263 // stack frame was an arguments adapter frame. | 262 // stack frame was an arguments adapter frame. |
264 ArgumentsAccessStub::Type type; | 263 ArgumentsAccessStub::Type type; |
265 if (strict_mode() == STRICT) { | 264 if (strict_mode() == STRICT) { |
266 type = ArgumentsAccessStub::NEW_STRICT; | 265 type = ArgumentsAccessStub::NEW_STRICT; |
267 } else if (function()->has_duplicate_parameters()) { | 266 } else if (function()->has_duplicate_parameters()) { |
268 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; | 267 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; |
269 } else { | 268 } else { |
270 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; | 269 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; |
271 } | 270 } |
272 ArgumentsAccessStub stub(isolate(), type); | 271 ArgumentsAccessStub stub(isolate(), type); |
273 __ CallStub(&stub); | 272 __ CallStub(&stub); |
274 | 273 |
275 SetVar(arguments, r0, r1, r2); | 274 SetVar(arguments, r3, r4, r5); |
276 } | 275 } |
277 | 276 |
278 if (FLAG_trace) { | 277 if (FLAG_trace) { |
279 __ CallRuntime(Runtime::kTraceEnter, 0); | 278 __ CallRuntime(Runtime::kTraceEnter, 0); |
280 } | 279 } |
281 | 280 |
282 // Visit the declarations and body unless there is an illegal | 281 // Visit the declarations and body unless there is an illegal |
283 // redeclaration. | 282 // redeclaration. |
284 if (scope()->HasIllegalRedeclaration()) { | 283 if (scope()->HasIllegalRedeclaration()) { |
285 Comment cmnt(masm_, "[ Declarations"); | 284 Comment cmnt(masm_, "[ Declarations"); |
286 scope()->VisitIllegalRedeclaration(this); | 285 scope()->VisitIllegalRedeclaration(this); |
287 | 286 |
288 } else { | 287 } else { |
289 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); | 288 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); |
290 { Comment cmnt(masm_, "[ Declarations"); | 289 { |
| 290 Comment cmnt(masm_, "[ Declarations"); |
291 // For named function expressions, declare the function name as a | 291 // For named function expressions, declare the function name as a |
292 // constant. | 292 // constant. |
293 if (scope()->is_function_scope() && scope()->function() != NULL) { | 293 if (scope()->is_function_scope() && scope()->function() != NULL) { |
294 VariableDeclaration* function = scope()->function(); | 294 VariableDeclaration* function = scope()->function(); |
295 DCHECK(function->proxy()->var()->mode() == CONST || | 295 DCHECK(function->proxy()->var()->mode() == CONST || |
296 function->proxy()->var()->mode() == CONST_LEGACY); | 296 function->proxy()->var()->mode() == CONST_LEGACY); |
297 DCHECK(function->proxy()->var()->location() != Variable::UNALLOCATED); | 297 DCHECK(function->proxy()->var()->location() != Variable::UNALLOCATED); |
298 VisitVariableDeclaration(function); | 298 VisitVariableDeclaration(function); |
299 } | 299 } |
300 VisitDeclarations(scope()->declarations()); | 300 VisitDeclarations(scope()->declarations()); |
301 } | 301 } |
302 | 302 |
303 { Comment cmnt(masm_, "[ Stack check"); | 303 { |
| 304 Comment cmnt(masm_, "[ Stack check"); |
304 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); | 305 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); |
305 Label ok; | 306 Label ok; |
306 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | 307 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
307 __ cmp(sp, Operand(ip)); | 308 __ cmpl(sp, ip); |
308 __ b(hs, &ok); | 309 __ bc_short(ge, &ok); |
309 Handle<Code> stack_check = isolate()->builtins()->StackCheck(); | 310 __ Call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); |
310 PredictableCodeSizeScope predictable(masm_, | |
311 masm_->CallSize(stack_check, RelocInfo::CODE_TARGET)); | |
312 __ Call(stack_check, RelocInfo::CODE_TARGET); | |
313 __ bind(&ok); | 311 __ bind(&ok); |
314 } | 312 } |
315 | 313 |
316 { Comment cmnt(masm_, "[ Body"); | 314 { |
| 315 Comment cmnt(masm_, "[ Body"); |
317 DCHECK(loop_depth() == 0); | 316 DCHECK(loop_depth() == 0); |
318 VisitStatements(function()->body()); | 317 VisitStatements(function()->body()); |
319 DCHECK(loop_depth() == 0); | 318 DCHECK(loop_depth() == 0); |
320 } | 319 } |
321 } | 320 } |
322 | 321 |
323 // Always emit a 'return undefined' in case control fell off the end of | 322 // Always emit a 'return undefined' in case control fell off the end of |
324 // the body. | 323 // the body. |
325 { Comment cmnt(masm_, "[ return <undefined>;"); | 324 { |
326 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 325 Comment cmnt(masm_, "[ return <undefined>;"); |
| 326 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
327 } | 327 } |
328 EmitReturnSequence(); | 328 EmitReturnSequence(); |
329 | |
330 // Force emit the constant pool, so it doesn't get emitted in the middle | |
331 // of the back edge table. | |
332 masm()->CheckConstPool(true, false); | |
333 } | 329 } |
334 | 330 |
335 | 331 |
336 void FullCodeGenerator::ClearAccumulator() { | 332 void FullCodeGenerator::ClearAccumulator() { |
337 __ mov(r0, Operand(Smi::FromInt(0))); | 333 __ LoadSmiLiteral(r3, Smi::FromInt(0)); |
338 } | 334 } |
339 | 335 |
340 | 336 |
341 void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) { | 337 void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) { |
342 __ mov(r2, Operand(profiling_counter_)); | 338 __ mov(r5, Operand(profiling_counter_)); |
343 __ ldr(r3, FieldMemOperand(r2, Cell::kValueOffset)); | 339 __ LoadP(r6, FieldMemOperand(r5, Cell::kValueOffset)); |
344 __ sub(r3, r3, Operand(Smi::FromInt(delta)), SetCC); | 340 __ SubSmiLiteral(r6, r6, Smi::FromInt(delta), r0); |
345 __ str(r3, FieldMemOperand(r2, Cell::kValueOffset)); | 341 __ StoreP(r6, FieldMemOperand(r5, Cell::kValueOffset), r0); |
346 } | 342 } |
347 | 343 |
348 | 344 |
349 static const int kProfileCounterResetSequenceLength = 5 * Assembler::kInstrSize; | |
350 | |
351 | |
352 void FullCodeGenerator::EmitProfilingCounterReset() { | 345 void FullCodeGenerator::EmitProfilingCounterReset() { |
353 Assembler::BlockConstPoolScope block_const_pool(masm_); | |
354 PredictableCodeSizeScope predictable_code_size_scope( | |
355 masm_, kProfileCounterResetSequenceLength); | |
356 Label start; | |
357 __ bind(&start); | |
358 int reset_value = FLAG_interrupt_budget; | 346 int reset_value = FLAG_interrupt_budget; |
359 if (info_->is_debug()) { | 347 if (info_->is_debug()) { |
360 // Detect debug break requests as soon as possible. | 348 // Detect debug break requests as soon as possible. |
361 reset_value = FLAG_interrupt_budget >> 4; | 349 reset_value = FLAG_interrupt_budget >> 4; |
362 } | 350 } |
363 __ mov(r2, Operand(profiling_counter_)); | 351 __ mov(r5, Operand(profiling_counter_)); |
364 // The mov instruction above can be either 1, 2 or 3 instructions depending | 352 __ LoadSmiLiteral(r6, Smi::FromInt(reset_value)); |
365 // upon whether it is an extended constant pool - insert nop to compensate. | 353 __ StoreP(r6, FieldMemOperand(r5, Cell::kValueOffset), r0); |
366 DCHECK(masm_->InstructionsGeneratedSince(&start) <= 3); | |
367 while (masm_->InstructionsGeneratedSince(&start) != 3) { | |
368 __ nop(); | |
369 } | |
370 __ mov(r3, Operand(Smi::FromInt(reset_value))); | |
371 __ str(r3, FieldMemOperand(r2, Cell::kValueOffset)); | |
372 } | 354 } |
373 | 355 |
374 | 356 |
375 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, | 357 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, |
376 Label* back_edge_target) { | 358 Label* back_edge_target) { |
377 Comment cmnt(masm_, "[ Back edge bookkeeping"); | 359 Comment cmnt(masm_, "[ Back edge bookkeeping"); |
378 // Block literal pools whilst emitting back edge code. | |
379 Assembler::BlockConstPoolScope block_const_pool(masm_); | |
380 Label ok; | 360 Label ok; |
381 | 361 |
382 DCHECK(back_edge_target->is_bound()); | 362 DCHECK(back_edge_target->is_bound()); |
383 int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target); | 363 int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target); |
384 int weight = Min(kMaxBackEdgeWeight, | 364 int weight = Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier)); |
385 Max(1, distance / kCodeSizeMultiplier)); | |
386 EmitProfilingCounterDecrement(weight); | 365 EmitProfilingCounterDecrement(weight); |
387 __ b(pl, &ok); | 366 { |
388 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); | 367 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); |
| 368 // BackEdgeTable::PatchAt manipulates this sequence. |
| 369 __ cmpi(r6, Operand::Zero()); |
| 370 __ bc_short(ge, &ok); |
| 371 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
389 | 372 |
390 // Record a mapping of this PC offset to the OSR id. This is used to find | 373 // Record a mapping of this PC offset to the OSR id. This is used to find |
391 // the AST id from the unoptimized code in order to use it as a key into | 374 // the AST id from the unoptimized code in order to use it as a key into |
392 // the deoptimization input data found in the optimized code. | 375 // the deoptimization input data found in the optimized code. |
393 RecordBackEdge(stmt->OsrEntryId()); | 376 RecordBackEdge(stmt->OsrEntryId()); |
394 | 377 } |
395 EmitProfilingCounterReset(); | 378 EmitProfilingCounterReset(); |
396 | 379 |
397 __ bind(&ok); | 380 __ bind(&ok); |
398 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 381 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); |
399 // Record a mapping of the OSR id to this PC. This is used if the OSR | 382 // Record a mapping of the OSR id to this PC. This is used if the OSR |
400 // entry becomes the target of a bailout. We don't expect it to be, but | 383 // entry becomes the target of a bailout. We don't expect it to be, but |
401 // we want it to work if it is. | 384 // we want it to work if it is. |
402 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); | 385 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); |
403 } | 386 } |
404 | 387 |
405 | 388 |
406 void FullCodeGenerator::EmitReturnSequence() { | 389 void FullCodeGenerator::EmitReturnSequence() { |
407 Comment cmnt(masm_, "[ Return sequence"); | 390 Comment cmnt(masm_, "[ Return sequence"); |
408 if (return_label_.is_bound()) { | 391 if (return_label_.is_bound()) { |
409 __ b(&return_label_); | 392 __ b(&return_label_); |
410 } else { | 393 } else { |
411 __ bind(&return_label_); | 394 __ bind(&return_label_); |
412 if (FLAG_trace) { | 395 if (FLAG_trace) { |
413 // Push the return value on the stack as the parameter. | 396 // Push the return value on the stack as the parameter. |
414 // Runtime::TraceExit returns its parameter in r0. | 397 // Runtime::TraceExit returns its parameter in r3 |
415 __ push(r0); | 398 __ push(r3); |
416 __ CallRuntime(Runtime::kTraceExit, 1); | 399 __ CallRuntime(Runtime::kTraceExit, 1); |
417 } | 400 } |
418 // Pretend that the exit is a backwards jump to the entry. | 401 // Pretend that the exit is a backwards jump to the entry. |
419 int weight = 1; | 402 int weight = 1; |
420 if (info_->ShouldSelfOptimize()) { | 403 if (info_->ShouldSelfOptimize()) { |
421 weight = FLAG_interrupt_budget / FLAG_self_opt_count; | 404 weight = FLAG_interrupt_budget / FLAG_self_opt_count; |
422 } else { | 405 } else { |
423 int distance = masm_->pc_offset(); | 406 int distance = masm_->pc_offset(); |
424 weight = Min(kMaxBackEdgeWeight, | 407 weight = Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier)); |
425 Max(1, distance / kCodeSizeMultiplier)); | |
426 } | 408 } |
427 EmitProfilingCounterDecrement(weight); | 409 EmitProfilingCounterDecrement(weight); |
428 Label ok; | 410 Label ok; |
429 __ b(pl, &ok); | 411 __ cmpi(r6, Operand::Zero()); |
430 __ push(r0); | 412 __ bge(&ok); |
431 __ Call(isolate()->builtins()->InterruptCheck(), | 413 __ push(r3); |
432 RelocInfo::CODE_TARGET); | 414 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
433 __ pop(r0); | 415 __ pop(r3); |
434 EmitProfilingCounterReset(); | 416 EmitProfilingCounterReset(); |
435 __ bind(&ok); | 417 __ bind(&ok); |
436 | 418 |
437 #ifdef DEBUG | 419 #ifdef DEBUG |
438 // Add a label for checking the size of the code used for returning. | 420 // Add a label for checking the size of the code used for returning. |
439 Label check_exit_codesize; | 421 Label check_exit_codesize; |
440 __ bind(&check_exit_codesize); | 422 __ bind(&check_exit_codesize); |
441 #endif | 423 #endif |
442 // Make sure that the constant pool is not emitted inside of the return | 424 // Make sure that the constant pool is not emitted inside of the return |
443 // sequence. | 425 // sequence. |
444 { Assembler::BlockConstPoolScope block_const_pool(masm_); | 426 { |
| 427 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); |
| 428 #if V8_OOL_CONSTANT_POOL |
| 429 ConstantPoolUnavailableScope constant_pool_unavailable(masm_); |
| 430 #endif |
445 int32_t sp_delta = (info_->scope()->num_parameters() + 1) * kPointerSize; | 431 int32_t sp_delta = (info_->scope()->num_parameters() + 1) * kPointerSize; |
446 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); | 432 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); |
447 // TODO(svenpanne) The code below is sometimes 4 words, sometimes 5! | |
448 PredictableCodeSizeScope predictable(masm_, -1); | |
449 __ RecordJSReturn(); | 433 __ RecordJSReturn(); |
450 int no_frame_start = __ LeaveFrame(StackFrame::JAVA_SCRIPT); | 434 int no_frame_start = __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
451 __ add(sp, sp, Operand(sp_delta)); | 435 __ Add(sp, sp, sp_delta, r0); |
452 __ Jump(lr); | 436 __ blr(); |
453 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 437 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
| 438 #if V8_TARGET_ARCH_PPC64 && !V8_OOL_CONSTANT_POOL |
| 439 // With 64bit we need a nop() instructions to ensure we have |
| 440 // enough space to SetDebugBreakAtReturn() |
| 441 masm_->nop(); |
| 442 #endif |
454 } | 443 } |
455 | 444 |
456 #ifdef DEBUG | 445 #ifdef DEBUG |
457 // Check that the size of the code used for returning is large enough | 446 // Check that the size of the code used for returning is large enough |
458 // for the debugger's requirements. | 447 // for the debugger's requirements. |
459 DCHECK(Assembler::kJSReturnSequenceInstructions <= | 448 DCHECK(Assembler::kJSReturnSequenceInstructions <= |
460 masm_->InstructionsGeneratedSince(&check_exit_codesize)); | 449 masm_->InstructionsGeneratedSince(&check_exit_codesize)); |
461 #endif | 450 #endif |
462 } | 451 } |
463 } | 452 } |
(...skipping 19 matching lines...) Expand all Loading... |
483 | 472 |
484 void FullCodeGenerator::TestContext::Plug(Variable* var) const { | 473 void FullCodeGenerator::TestContext::Plug(Variable* var) const { |
485 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 474 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
486 // For simplicity we always test the accumulator register. | 475 // For simplicity we always test the accumulator register. |
487 codegen()->GetVar(result_register(), var); | 476 codegen()->GetVar(result_register(), var); |
488 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); | 477 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); |
489 codegen()->DoTest(this); | 478 codegen()->DoTest(this); |
490 } | 479 } |
491 | 480 |
492 | 481 |
493 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { | 482 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const {} |
494 } | |
495 | 483 |
496 | 484 |
497 void FullCodeGenerator::AccumulatorValueContext::Plug( | 485 void FullCodeGenerator::AccumulatorValueContext::Plug( |
498 Heap::RootListIndex index) const { | 486 Heap::RootListIndex index) const { |
499 __ LoadRoot(result_register(), index); | 487 __ LoadRoot(result_register(), index); |
500 } | 488 } |
501 | 489 |
502 | 490 |
503 void FullCodeGenerator::StackValueContext::Plug( | 491 void FullCodeGenerator::StackValueContext::Plug( |
504 Heap::RootListIndex index) const { | 492 Heap::RootListIndex index) const { |
505 __ LoadRoot(result_register(), index); | 493 __ LoadRoot(result_register(), index); |
506 __ push(result_register()); | 494 __ push(result_register()); |
507 } | 495 } |
508 | 496 |
509 | 497 |
510 void FullCodeGenerator::TestContext::Plug(Heap::RootListIndex index) const { | 498 void FullCodeGenerator::TestContext::Plug(Heap::RootListIndex index) const { |
511 codegen()->PrepareForBailoutBeforeSplit(condition(), | 499 codegen()->PrepareForBailoutBeforeSplit(condition(), true, true_label_, |
512 true, | |
513 true_label_, | |
514 false_label_); | 500 false_label_); |
515 if (index == Heap::kUndefinedValueRootIndex || | 501 if (index == Heap::kUndefinedValueRootIndex || |
516 index == Heap::kNullValueRootIndex || | 502 index == Heap::kNullValueRootIndex || |
517 index == Heap::kFalseValueRootIndex) { | 503 index == Heap::kFalseValueRootIndex) { |
518 if (false_label_ != fall_through_) __ b(false_label_); | 504 if (false_label_ != fall_through_) __ b(false_label_); |
519 } else if (index == Heap::kTrueValueRootIndex) { | 505 } else if (index == Heap::kTrueValueRootIndex) { |
520 if (true_label_ != fall_through_) __ b(true_label_); | 506 if (true_label_ != fall_through_) __ b(true_label_); |
521 } else { | 507 } else { |
522 __ LoadRoot(result_register(), index); | 508 __ LoadRoot(result_register(), index); |
523 codegen()->DoTest(this); | 509 codegen()->DoTest(this); |
524 } | 510 } |
525 } | 511 } |
526 | 512 |
527 | 513 |
528 void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const { | 514 void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {} |
529 } | |
530 | 515 |
531 | 516 |
532 void FullCodeGenerator::AccumulatorValueContext::Plug( | 517 void FullCodeGenerator::AccumulatorValueContext::Plug( |
533 Handle<Object> lit) const { | 518 Handle<Object> lit) const { |
534 __ mov(result_register(), Operand(lit)); | 519 __ mov(result_register(), Operand(lit)); |
535 } | 520 } |
536 | 521 |
537 | 522 |
538 void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const { | 523 void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const { |
539 // Immediates cannot be pushed directly. | 524 // Immediates cannot be pushed directly. |
540 __ mov(result_register(), Operand(lit)); | 525 __ mov(result_register(), Operand(lit)); |
541 __ push(result_register()); | 526 __ push(result_register()); |
542 } | 527 } |
543 | 528 |
544 | 529 |
545 void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const { | 530 void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const { |
546 codegen()->PrepareForBailoutBeforeSplit(condition(), | 531 codegen()->PrepareForBailoutBeforeSplit(condition(), true, true_label_, |
547 true, | |
548 true_label_, | |
549 false_label_); | 532 false_label_); |
550 DCHECK(!lit->IsUndetectableObject()); // There are no undetectable literals. | 533 DCHECK(!lit->IsUndetectableObject()); // There are no undetectable literals. |
551 if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) { | 534 if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) { |
552 if (false_label_ != fall_through_) __ b(false_label_); | 535 if (false_label_ != fall_through_) __ b(false_label_); |
553 } else if (lit->IsTrue() || lit->IsJSObject()) { | 536 } else if (lit->IsTrue() || lit->IsJSObject()) { |
554 if (true_label_ != fall_through_) __ b(true_label_); | 537 if (true_label_ != fall_through_) __ b(true_label_); |
555 } else if (lit->IsString()) { | 538 } else if (lit->IsString()) { |
556 if (String::cast(*lit)->length() == 0) { | 539 if (String::cast(*lit)->length() == 0) { |
557 if (false_label_ != fall_through_) __ b(false_label_); | 540 if (false_label_ != fall_through_) __ b(false_label_); |
558 } else { | 541 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
573 | 556 |
574 | 557 |
575 void FullCodeGenerator::EffectContext::DropAndPlug(int count, | 558 void FullCodeGenerator::EffectContext::DropAndPlug(int count, |
576 Register reg) const { | 559 Register reg) const { |
577 DCHECK(count > 0); | 560 DCHECK(count > 0); |
578 __ Drop(count); | 561 __ Drop(count); |
579 } | 562 } |
580 | 563 |
581 | 564 |
582 void FullCodeGenerator::AccumulatorValueContext::DropAndPlug( | 565 void FullCodeGenerator::AccumulatorValueContext::DropAndPlug( |
583 int count, | 566 int count, Register reg) const { |
584 Register reg) const { | |
585 DCHECK(count > 0); | 567 DCHECK(count > 0); |
586 __ Drop(count); | 568 __ Drop(count); |
587 __ Move(result_register(), reg); | 569 __ Move(result_register(), reg); |
588 } | 570 } |
589 | 571 |
590 | 572 |
591 void FullCodeGenerator::StackValueContext::DropAndPlug(int count, | 573 void FullCodeGenerator::StackValueContext::DropAndPlug(int count, |
592 Register reg) const { | 574 Register reg) const { |
593 DCHECK(count > 0); | 575 DCHECK(count > 0); |
594 if (count > 1) __ Drop(count - 1); | 576 if (count > 1) __ Drop(count - 1); |
595 __ str(reg, MemOperand(sp, 0)); | 577 __ StoreP(reg, MemOperand(sp, 0)); |
596 } | 578 } |
597 | 579 |
598 | 580 |
599 void FullCodeGenerator::TestContext::DropAndPlug(int count, | 581 void FullCodeGenerator::TestContext::DropAndPlug(int count, |
600 Register reg) const { | 582 Register reg) const { |
601 DCHECK(count > 0); | 583 DCHECK(count > 0); |
602 // For simplicity we always test the accumulator register. | 584 // For simplicity we always test the accumulator register. |
603 __ Drop(count); | 585 __ Drop(count); |
604 __ Move(result_register(), reg); | 586 __ Move(result_register(), reg); |
605 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); | 587 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); |
606 codegen()->DoTest(this); | 588 codegen()->DoTest(this); |
607 } | 589 } |
608 | 590 |
609 | 591 |
610 void FullCodeGenerator::EffectContext::Plug(Label* materialize_true, | 592 void FullCodeGenerator::EffectContext::Plug(Label* materialize_true, |
611 Label* materialize_false) const { | 593 Label* materialize_false) const { |
612 DCHECK(materialize_true == materialize_false); | 594 DCHECK(materialize_true == materialize_false); |
613 __ bind(materialize_true); | 595 __ bind(materialize_true); |
614 } | 596 } |
615 | 597 |
616 | 598 |
617 void FullCodeGenerator::AccumulatorValueContext::Plug( | 599 void FullCodeGenerator::AccumulatorValueContext::Plug( |
618 Label* materialize_true, | 600 Label* materialize_true, Label* materialize_false) const { |
619 Label* materialize_false) const { | |
620 Label done; | 601 Label done; |
621 __ bind(materialize_true); | 602 __ bind(materialize_true); |
622 __ LoadRoot(result_register(), Heap::kTrueValueRootIndex); | 603 __ LoadRoot(result_register(), Heap::kTrueValueRootIndex); |
623 __ jmp(&done); | 604 __ b(&done); |
624 __ bind(materialize_false); | 605 __ bind(materialize_false); |
625 __ LoadRoot(result_register(), Heap::kFalseValueRootIndex); | 606 __ LoadRoot(result_register(), Heap::kFalseValueRootIndex); |
626 __ bind(&done); | 607 __ bind(&done); |
627 } | 608 } |
628 | 609 |
629 | 610 |
630 void FullCodeGenerator::StackValueContext::Plug( | 611 void FullCodeGenerator::StackValueContext::Plug( |
631 Label* materialize_true, | 612 Label* materialize_true, Label* materialize_false) const { |
632 Label* materialize_false) const { | |
633 Label done; | 613 Label done; |
634 __ bind(materialize_true); | 614 __ bind(materialize_true); |
635 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 615 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
636 __ jmp(&done); | 616 __ b(&done); |
637 __ bind(materialize_false); | 617 __ bind(materialize_false); |
638 __ LoadRoot(ip, Heap::kFalseValueRootIndex); | 618 __ LoadRoot(ip, Heap::kFalseValueRootIndex); |
639 __ bind(&done); | 619 __ bind(&done); |
640 __ push(ip); | 620 __ push(ip); |
641 } | 621 } |
642 | 622 |
643 | 623 |
644 void FullCodeGenerator::TestContext::Plug(Label* materialize_true, | 624 void FullCodeGenerator::TestContext::Plug(Label* materialize_true, |
645 Label* materialize_false) const { | 625 Label* materialize_false) const { |
646 DCHECK(materialize_true == true_label_); | 626 DCHECK(materialize_true == true_label_); |
647 DCHECK(materialize_false == false_label_); | 627 DCHECK(materialize_false == false_label_); |
648 } | 628 } |
649 | 629 |
650 | 630 |
651 void FullCodeGenerator::EffectContext::Plug(bool flag) const { | 631 void FullCodeGenerator::EffectContext::Plug(bool flag) const {} |
652 } | |
653 | 632 |
654 | 633 |
655 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { | 634 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { |
656 Heap::RootListIndex value_root_index = | 635 Heap::RootListIndex value_root_index = |
657 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; | 636 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
658 __ LoadRoot(result_register(), value_root_index); | 637 __ LoadRoot(result_register(), value_root_index); |
659 } | 638 } |
660 | 639 |
661 | 640 |
662 void FullCodeGenerator::StackValueContext::Plug(bool flag) const { | 641 void FullCodeGenerator::StackValueContext::Plug(bool flag) const { |
663 Heap::RootListIndex value_root_index = | 642 Heap::RootListIndex value_root_index = |
664 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; | 643 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
665 __ LoadRoot(ip, value_root_index); | 644 __ LoadRoot(ip, value_root_index); |
666 __ push(ip); | 645 __ push(ip); |
667 } | 646 } |
668 | 647 |
669 | 648 |
670 void FullCodeGenerator::TestContext::Plug(bool flag) const { | 649 void FullCodeGenerator::TestContext::Plug(bool flag) const { |
671 codegen()->PrepareForBailoutBeforeSplit(condition(), | 650 codegen()->PrepareForBailoutBeforeSplit(condition(), true, true_label_, |
672 true, | |
673 true_label_, | |
674 false_label_); | 651 false_label_); |
675 if (flag) { | 652 if (flag) { |
676 if (true_label_ != fall_through_) __ b(true_label_); | 653 if (true_label_ != fall_through_) __ b(true_label_); |
677 } else { | 654 } else { |
678 if (false_label_ != fall_through_) __ b(false_label_); | 655 if (false_label_ != fall_through_) __ b(false_label_); |
679 } | 656 } |
680 } | 657 } |
681 | 658 |
682 | 659 |
683 void FullCodeGenerator::DoTest(Expression* condition, | 660 void FullCodeGenerator::DoTest(Expression* condition, Label* if_true, |
684 Label* if_true, | 661 Label* if_false, Label* fall_through) { |
685 Label* if_false, | |
686 Label* fall_through) { | |
687 Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate()); | 662 Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate()); |
688 CallIC(ic, condition->test_id()); | 663 CallIC(ic, condition->test_id()); |
689 __ tst(result_register(), result_register()); | 664 __ cmpi(result_register(), Operand::Zero()); |
690 Split(ne, if_true, if_false, fall_through); | 665 Split(ne, if_true, if_false, fall_through); |
691 } | 666 } |
692 | 667 |
693 | 668 |
694 void FullCodeGenerator::Split(Condition cond, | 669 void FullCodeGenerator::Split(Condition cond, Label* if_true, Label* if_false, |
695 Label* if_true, | 670 Label* fall_through, CRegister cr) { |
696 Label* if_false, | |
697 Label* fall_through) { | |
698 if (if_false == fall_through) { | 671 if (if_false == fall_through) { |
699 __ b(cond, if_true); | 672 __ b(cond, if_true, cr); |
700 } else if (if_true == fall_through) { | 673 } else if (if_true == fall_through) { |
701 __ b(NegateCondition(cond), if_false); | 674 __ b(NegateCondition(cond), if_false, cr); |
702 } else { | 675 } else { |
703 __ b(cond, if_true); | 676 __ b(cond, if_true, cr); |
704 __ b(if_false); | 677 __ b(if_false); |
705 } | 678 } |
706 } | 679 } |
707 | 680 |
708 | 681 |
709 MemOperand FullCodeGenerator::StackOperand(Variable* var) { | 682 MemOperand FullCodeGenerator::StackOperand(Variable* var) { |
710 DCHECK(var->IsStackAllocated()); | 683 DCHECK(var->IsStackAllocated()); |
711 // Offset is negative because higher indexes are at lower addresses. | 684 // Offset is negative because higher indexes are at lower addresses. |
712 int offset = -var->index() * kPointerSize; | 685 int offset = -var->index() * kPointerSize; |
713 // Adjust by a (parameter or local) base offset. | 686 // Adjust by a (parameter or local) base offset. |
(...skipping 14 matching lines...) Expand all Loading... |
728 return ContextOperand(scratch, var->index()); | 701 return ContextOperand(scratch, var->index()); |
729 } else { | 702 } else { |
730 return StackOperand(var); | 703 return StackOperand(var); |
731 } | 704 } |
732 } | 705 } |
733 | 706 |
734 | 707 |
735 void FullCodeGenerator::GetVar(Register dest, Variable* var) { | 708 void FullCodeGenerator::GetVar(Register dest, Variable* var) { |
736 // Use destination as scratch. | 709 // Use destination as scratch. |
737 MemOperand location = VarOperand(var, dest); | 710 MemOperand location = VarOperand(var, dest); |
738 __ ldr(dest, location); | 711 __ LoadP(dest, location, r0); |
739 } | 712 } |
740 | 713 |
741 | 714 |
742 void FullCodeGenerator::SetVar(Variable* var, | 715 void FullCodeGenerator::SetVar(Variable* var, Register src, Register scratch0, |
743 Register src, | |
744 Register scratch0, | |
745 Register scratch1) { | 716 Register scratch1) { |
746 DCHECK(var->IsContextSlot() || var->IsStackAllocated()); | 717 DCHECK(var->IsContextSlot() || var->IsStackAllocated()); |
747 DCHECK(!scratch0.is(src)); | 718 DCHECK(!scratch0.is(src)); |
748 DCHECK(!scratch0.is(scratch1)); | 719 DCHECK(!scratch0.is(scratch1)); |
749 DCHECK(!scratch1.is(src)); | 720 DCHECK(!scratch1.is(src)); |
750 MemOperand location = VarOperand(var, scratch0); | 721 MemOperand location = VarOperand(var, scratch0); |
751 __ str(src, location); | 722 __ StoreP(src, location, r0); |
752 | 723 |
753 // Emit the write barrier code if the location is in the heap. | 724 // Emit the write barrier code if the location is in the heap. |
754 if (var->IsContextSlot()) { | 725 if (var->IsContextSlot()) { |
755 __ RecordWriteContextSlot(scratch0, | 726 __ RecordWriteContextSlot(scratch0, location.offset(), src, scratch1, |
756 location.offset(), | 727 kLRHasBeenSaved, kDontSaveFPRegs); |
757 src, | |
758 scratch1, | |
759 kLRHasBeenSaved, | |
760 kDontSaveFPRegs); | |
761 } | 728 } |
762 } | 729 } |
763 | 730 |
764 | 731 |
765 void FullCodeGenerator::PrepareForBailoutBeforeSplit(Expression* expr, | 732 void FullCodeGenerator::PrepareForBailoutBeforeSplit(Expression* expr, |
766 bool should_normalize, | 733 bool should_normalize, |
767 Label* if_true, | 734 Label* if_true, |
768 Label* if_false) { | 735 Label* if_false) { |
769 // Only prepare for bailouts before splits if we're in a test | 736 // Only prepare for bailouts before splits if we're in a test |
770 // context. Otherwise, we let the Visit function deal with the | 737 // context. Otherwise, we let the Visit function deal with the |
771 // preparation to avoid preparing with the same AST id twice. | 738 // preparation to avoid preparing with the same AST id twice. |
772 if (!context()->IsTest() || !info_->IsOptimizable()) return; | 739 if (!context()->IsTest() || !info_->IsOptimizable()) return; |
773 | 740 |
774 Label skip; | 741 Label skip; |
775 if (should_normalize) __ b(&skip); | 742 if (should_normalize) __ b(&skip); |
776 PrepareForBailout(expr, TOS_REG); | 743 PrepareForBailout(expr, TOS_REG); |
777 if (should_normalize) { | 744 if (should_normalize) { |
778 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 745 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
779 __ cmp(r0, ip); | 746 __ cmp(r3, ip); |
780 Split(eq, if_true, if_false, NULL); | 747 Split(eq, if_true, if_false, NULL); |
781 __ bind(&skip); | 748 __ bind(&skip); |
782 } | 749 } |
783 } | 750 } |
784 | 751 |
785 | 752 |
786 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { | 753 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { |
787 // The variable in the declaration always resides in the current function | 754 // The variable in the declaration always resides in the current function |
788 // context. | 755 // context. |
789 DCHECK_EQ(0, scope()->ContextChainLength(variable->scope())); | 756 DCHECK_EQ(0, scope()->ContextChainLength(variable->scope())); |
790 if (generate_debug_code_) { | 757 if (generate_debug_code_) { |
791 // Check that we're not inside a with or catch context. | 758 // Check that we're not inside a with or catch context. |
792 __ ldr(r1, FieldMemOperand(cp, HeapObject::kMapOffset)); | 759 __ LoadP(r4, FieldMemOperand(cp, HeapObject::kMapOffset)); |
793 __ CompareRoot(r1, Heap::kWithContextMapRootIndex); | 760 __ CompareRoot(r4, Heap::kWithContextMapRootIndex); |
794 __ Check(ne, kDeclarationInWithContext); | 761 __ Check(ne, kDeclarationInWithContext); |
795 __ CompareRoot(r1, Heap::kCatchContextMapRootIndex); | 762 __ CompareRoot(r4, Heap::kCatchContextMapRootIndex); |
796 __ Check(ne, kDeclarationInCatchContext); | 763 __ Check(ne, kDeclarationInCatchContext); |
797 } | 764 } |
798 } | 765 } |
799 | 766 |
800 | 767 |
801 void FullCodeGenerator::VisitVariableDeclaration( | 768 void FullCodeGenerator::VisitVariableDeclaration( |
802 VariableDeclaration* declaration) { | 769 VariableDeclaration* declaration) { |
803 // If it was not possible to allocate the variable at compile time, we | 770 // If it was not possible to allocate the variable at compile time, we |
804 // need to "declare" it at runtime to make sure it actually exists in the | 771 // need to "declare" it at runtime to make sure it actually exists in the |
805 // local context. | 772 // local context. |
806 VariableProxy* proxy = declaration->proxy(); | 773 VariableProxy* proxy = declaration->proxy(); |
807 VariableMode mode = declaration->mode(); | 774 VariableMode mode = declaration->mode(); |
808 Variable* variable = proxy->var(); | 775 Variable* variable = proxy->var(); |
809 bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; | 776 bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; |
810 switch (variable->location()) { | 777 switch (variable->location()) { |
811 case Variable::UNALLOCATED: | 778 case Variable::UNALLOCATED: |
812 globals_->Add(variable->name(), zone()); | 779 globals_->Add(variable->name(), zone()); |
813 globals_->Add(variable->binding_needs_init() | 780 globals_->Add(variable->binding_needs_init() |
814 ? isolate()->factory()->the_hole_value() | 781 ? isolate()->factory()->the_hole_value() |
815 : isolate()->factory()->undefined_value(), | 782 : isolate()->factory()->undefined_value(), |
816 zone()); | 783 zone()); |
817 break; | 784 break; |
818 | 785 |
819 case Variable::PARAMETER: | 786 case Variable::PARAMETER: |
820 case Variable::LOCAL: | 787 case Variable::LOCAL: |
821 if (hole_init) { | 788 if (hole_init) { |
822 Comment cmnt(masm_, "[ VariableDeclaration"); | 789 Comment cmnt(masm_, "[ VariableDeclaration"); |
823 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 790 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
824 __ str(ip, StackOperand(variable)); | 791 __ StoreP(ip, StackOperand(variable)); |
825 } | 792 } |
826 break; | 793 break; |
827 | 794 |
828 case Variable::CONTEXT: | 795 case Variable::CONTEXT: |
829 if (hole_init) { | 796 if (hole_init) { |
830 Comment cmnt(masm_, "[ VariableDeclaration"); | 797 Comment cmnt(masm_, "[ VariableDeclaration"); |
831 EmitDebugCheckDeclarationContext(variable); | 798 EmitDebugCheckDeclarationContext(variable); |
832 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 799 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
833 __ str(ip, ContextOperand(cp, variable->index())); | 800 __ StoreP(ip, ContextOperand(cp, variable->index()), r0); |
834 // No write barrier since the_hole_value is in old space. | 801 // No write barrier since the_hole_value is in old space. |
835 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 802 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
836 } | 803 } |
837 break; | 804 break; |
838 | 805 |
839 case Variable::LOOKUP: { | 806 case Variable::LOOKUP: { |
840 Comment cmnt(masm_, "[ VariableDeclaration"); | 807 Comment cmnt(masm_, "[ VariableDeclaration"); |
841 __ mov(r2, Operand(variable->name())); | 808 __ mov(r5, Operand(variable->name())); |
842 // Declaration nodes are always introduced in one of four modes. | 809 // Declaration nodes are always introduced in one of four modes. |
843 DCHECK(IsDeclaredVariableMode(mode)); | 810 DCHECK(IsDeclaredVariableMode(mode)); |
844 PropertyAttributes attr = | 811 PropertyAttributes attr = |
845 IsImmutableVariableMode(mode) ? READ_ONLY : NONE; | 812 IsImmutableVariableMode(mode) ? READ_ONLY : NONE; |
846 __ mov(r1, Operand(Smi::FromInt(attr))); | 813 __ LoadSmiLiteral(r4, Smi::FromInt(attr)); |
847 // Push initial value, if any. | 814 // Push initial value, if any. |
848 // Note: For variables we must not push an initial value (such as | 815 // Note: For variables we must not push an initial value (such as |
849 // 'undefined') because we may have a (legal) redeclaration and we | 816 // 'undefined') because we may have a (legal) redeclaration and we |
850 // must not destroy the current value. | 817 // must not destroy the current value. |
851 if (hole_init) { | 818 if (hole_init) { |
852 __ LoadRoot(r0, Heap::kTheHoleValueRootIndex); | 819 __ LoadRoot(r3, Heap::kTheHoleValueRootIndex); |
853 __ Push(cp, r2, r1, r0); | 820 __ Push(cp, r5, r4, r3); |
854 } else { | 821 } else { |
855 __ mov(r0, Operand(Smi::FromInt(0))); // Indicates no initial value. | 822 __ LoadSmiLiteral(r3, Smi::FromInt(0)); // Indicates no initial value. |
856 __ Push(cp, r2, r1, r0); | 823 __ Push(cp, r5, r4, r3); |
857 } | 824 } |
858 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); | 825 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); |
859 break; | 826 break; |
860 } | 827 } |
861 } | 828 } |
862 } | 829 } |
863 | 830 |
864 | 831 |
865 void FullCodeGenerator::VisitFunctionDeclaration( | 832 void FullCodeGenerator::VisitFunctionDeclaration( |
866 FunctionDeclaration* declaration) { | 833 FunctionDeclaration* declaration) { |
867 VariableProxy* proxy = declaration->proxy(); | 834 VariableProxy* proxy = declaration->proxy(); |
868 Variable* variable = proxy->var(); | 835 Variable* variable = proxy->var(); |
869 switch (variable->location()) { | 836 switch (variable->location()) { |
870 case Variable::UNALLOCATED: { | 837 case Variable::UNALLOCATED: { |
871 globals_->Add(variable->name(), zone()); | 838 globals_->Add(variable->name(), zone()); |
872 Handle<SharedFunctionInfo> function = | 839 Handle<SharedFunctionInfo> function = |
873 Compiler::BuildFunctionInfo(declaration->fun(), script(), info_); | 840 Compiler::BuildFunctionInfo(declaration->fun(), script(), info_); |
874 // Check for stack-overflow exception. | 841 // Check for stack-overflow exception. |
875 if (function.is_null()) return SetStackOverflow(); | 842 if (function.is_null()) return SetStackOverflow(); |
876 globals_->Add(function, zone()); | 843 globals_->Add(function, zone()); |
877 break; | 844 break; |
878 } | 845 } |
879 | 846 |
880 case Variable::PARAMETER: | 847 case Variable::PARAMETER: |
881 case Variable::LOCAL: { | 848 case Variable::LOCAL: { |
882 Comment cmnt(masm_, "[ FunctionDeclaration"); | 849 Comment cmnt(masm_, "[ FunctionDeclaration"); |
883 VisitForAccumulatorValue(declaration->fun()); | 850 VisitForAccumulatorValue(declaration->fun()); |
884 __ str(result_register(), StackOperand(variable)); | 851 __ StoreP(result_register(), StackOperand(variable)); |
885 break; | 852 break; |
886 } | 853 } |
887 | 854 |
888 case Variable::CONTEXT: { | 855 case Variable::CONTEXT: { |
889 Comment cmnt(masm_, "[ FunctionDeclaration"); | 856 Comment cmnt(masm_, "[ FunctionDeclaration"); |
890 EmitDebugCheckDeclarationContext(variable); | 857 EmitDebugCheckDeclarationContext(variable); |
891 VisitForAccumulatorValue(declaration->fun()); | 858 VisitForAccumulatorValue(declaration->fun()); |
892 __ str(result_register(), ContextOperand(cp, variable->index())); | 859 __ StoreP(result_register(), ContextOperand(cp, variable->index()), r0); |
893 int offset = Context::SlotOffset(variable->index()); | 860 int offset = Context::SlotOffset(variable->index()); |
894 // We know that we have written a function, which is not a smi. | 861 // We know that we have written a function, which is not a smi. |
895 __ RecordWriteContextSlot(cp, | 862 __ RecordWriteContextSlot(cp, offset, result_register(), r5, |
896 offset, | 863 kLRHasBeenSaved, kDontSaveFPRegs, |
897 result_register(), | 864 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
898 r2, | |
899 kLRHasBeenSaved, | |
900 kDontSaveFPRegs, | |
901 EMIT_REMEMBERED_SET, | |
902 OMIT_SMI_CHECK); | |
903 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 865 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
904 break; | 866 break; |
905 } | 867 } |
906 | 868 |
907 case Variable::LOOKUP: { | 869 case Variable::LOOKUP: { |
908 Comment cmnt(masm_, "[ FunctionDeclaration"); | 870 Comment cmnt(masm_, "[ FunctionDeclaration"); |
909 __ mov(r2, Operand(variable->name())); | 871 __ mov(r5, Operand(variable->name())); |
910 __ mov(r1, Operand(Smi::FromInt(NONE))); | 872 __ LoadSmiLiteral(r4, Smi::FromInt(NONE)); |
911 __ Push(cp, r2, r1); | 873 __ Push(cp, r5, r4); |
912 // Push initial value for function declaration. | 874 // Push initial value for function declaration. |
913 VisitForStackValue(declaration->fun()); | 875 VisitForStackValue(declaration->fun()); |
914 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); | 876 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); |
915 break; | 877 break; |
916 } | 878 } |
917 } | 879 } |
918 } | 880 } |
919 | 881 |
920 | 882 |
921 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 883 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
922 Variable* variable = declaration->proxy()->var(); | 884 Variable* variable = declaration->proxy()->var(); |
923 DCHECK(variable->location() == Variable::CONTEXT); | 885 DCHECK(variable->location() == Variable::CONTEXT); |
924 DCHECK(variable->interface()->IsFrozen()); | 886 DCHECK(variable->interface()->IsFrozen()); |
925 | 887 |
926 Comment cmnt(masm_, "[ ModuleDeclaration"); | 888 Comment cmnt(masm_, "[ ModuleDeclaration"); |
927 EmitDebugCheckDeclarationContext(variable); | 889 EmitDebugCheckDeclarationContext(variable); |
928 | 890 |
929 // Load instance object. | 891 // Load instance object. |
930 __ LoadContext(r1, scope_->ContextChainLength(scope_->GlobalScope())); | 892 __ LoadContext(r4, scope_->ContextChainLength(scope_->GlobalScope())); |
931 __ ldr(r1, ContextOperand(r1, variable->interface()->Index())); | 893 __ LoadP(r4, ContextOperand(r4, variable->interface()->Index())); |
932 __ ldr(r1, ContextOperand(r1, Context::EXTENSION_INDEX)); | 894 __ LoadP(r4, ContextOperand(r4, Context::EXTENSION_INDEX)); |
933 | 895 |
934 // Assign it. | 896 // Assign it. |
935 __ str(r1, ContextOperand(cp, variable->index())); | 897 __ StoreP(r4, ContextOperand(cp, variable->index()), r0); |
936 // We know that we have written a module, which is not a smi. | 898 // We know that we have written a module, which is not a smi. |
937 __ RecordWriteContextSlot(cp, | 899 __ RecordWriteContextSlot(cp, Context::SlotOffset(variable->index()), r4, r6, |
938 Context::SlotOffset(variable->index()), | 900 kLRHasBeenSaved, kDontSaveFPRegs, |
939 r1, | 901 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
940 r3, | |
941 kLRHasBeenSaved, | |
942 kDontSaveFPRegs, | |
943 EMIT_REMEMBERED_SET, | |
944 OMIT_SMI_CHECK); | |
945 PrepareForBailoutForId(declaration->proxy()->id(), NO_REGISTERS); | 902 PrepareForBailoutForId(declaration->proxy()->id(), NO_REGISTERS); |
946 | 903 |
947 // Traverse into body. | 904 // Traverse into body. |
948 Visit(declaration->module()); | 905 Visit(declaration->module()); |
949 } | 906 } |
950 | 907 |
951 | 908 |
952 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { | 909 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { |
953 VariableProxy* proxy = declaration->proxy(); | 910 VariableProxy* proxy = declaration->proxy(); |
954 Variable* variable = proxy->var(); | 911 Variable* variable = proxy->var(); |
(...skipping 18 matching lines...) Expand all Loading... |
973 | 930 |
974 | 931 |
975 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) { | 932 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) { |
976 // TODO(rossberg) | 933 // TODO(rossberg) |
977 } | 934 } |
978 | 935 |
979 | 936 |
980 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 937 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
981 // Call the runtime to declare the globals. | 938 // Call the runtime to declare the globals. |
982 // The context is the first argument. | 939 // The context is the first argument. |
983 __ mov(r1, Operand(pairs)); | 940 __ mov(r4, Operand(pairs)); |
984 __ mov(r0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); | 941 __ LoadSmiLiteral(r3, Smi::FromInt(DeclareGlobalsFlags())); |
985 __ Push(cp, r1, r0); | 942 __ Push(cp, r4, r3); |
986 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 943 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
987 // Return value is ignored. | 944 // Return value is ignored. |
988 } | 945 } |
989 | 946 |
990 | 947 |
991 void FullCodeGenerator::DeclareModules(Handle<FixedArray> descriptions) { | 948 void FullCodeGenerator::DeclareModules(Handle<FixedArray> descriptions) { |
992 // Call the runtime to declare the modules. | 949 // Call the runtime to declare the modules. |
993 __ Push(descriptions); | 950 __ Push(descriptions); |
994 __ CallRuntime(Runtime::kDeclareModules, 1); | 951 __ CallRuntime(Runtime::kDeclareModules, 1); |
995 // Return value is ignored. | 952 // Return value is ignored. |
(...skipping 25 matching lines...) Expand all Loading... |
1021 } | 978 } |
1022 | 979 |
1023 Comment cmnt(masm_, "[ Case comparison"); | 980 Comment cmnt(masm_, "[ Case comparison"); |
1024 __ bind(&next_test); | 981 __ bind(&next_test); |
1025 next_test.Unuse(); | 982 next_test.Unuse(); |
1026 | 983 |
1027 // Compile the label expression. | 984 // Compile the label expression. |
1028 VisitForAccumulatorValue(clause->label()); | 985 VisitForAccumulatorValue(clause->label()); |
1029 | 986 |
1030 // Perform the comparison as if via '==='. | 987 // Perform the comparison as if via '==='. |
1031 __ ldr(r1, MemOperand(sp, 0)); // Switch value. | 988 __ LoadP(r4, MemOperand(sp, 0)); // Switch value. |
1032 bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); | 989 bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); |
1033 JumpPatchSite patch_site(masm_); | 990 JumpPatchSite patch_site(masm_); |
1034 if (inline_smi_code) { | 991 if (inline_smi_code) { |
1035 Label slow_case; | 992 Label slow_case; |
1036 __ orr(r2, r1, r0); | 993 __ orx(r5, r4, r3); |
1037 patch_site.EmitJumpIfNotSmi(r2, &slow_case); | 994 patch_site.EmitJumpIfNotSmi(r5, &slow_case); |
1038 | 995 |
1039 __ cmp(r1, r0); | 996 __ cmp(r4, r3); |
1040 __ b(ne, &next_test); | 997 __ bne(&next_test); |
1041 __ Drop(1); // Switch value is no longer needed. | 998 __ Drop(1); // Switch value is no longer needed. |
1042 __ b(clause->body_target()); | 999 __ b(clause->body_target()); |
1043 __ bind(&slow_case); | 1000 __ bind(&slow_case); |
1044 } | 1001 } |
1045 | 1002 |
1046 // Record position before stub call for type feedback. | 1003 // Record position before stub call for type feedback. |
1047 SetSourcePosition(clause->position()); | 1004 SetSourcePosition(clause->position()); |
1048 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); | 1005 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); |
1049 CallIC(ic, clause->CompareId()); | 1006 CallIC(ic, clause->CompareId()); |
1050 patch_site.EmitPatchInfo(); | 1007 patch_site.EmitPatchInfo(); |
1051 | 1008 |
1052 Label skip; | 1009 Label skip; |
1053 __ b(&skip); | 1010 __ b(&skip); |
1054 PrepareForBailout(clause, TOS_REG); | 1011 PrepareForBailout(clause, TOS_REG); |
1055 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 1012 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
1056 __ cmp(r0, ip); | 1013 __ cmp(r3, ip); |
1057 __ b(ne, &next_test); | 1014 __ bne(&next_test); |
1058 __ Drop(1); | 1015 __ Drop(1); |
1059 __ jmp(clause->body_target()); | 1016 __ b(clause->body_target()); |
1060 __ bind(&skip); | 1017 __ bind(&skip); |
1061 | 1018 |
1062 __ cmp(r0, Operand::Zero()); | 1019 __ cmpi(r3, Operand::Zero()); |
1063 __ b(ne, &next_test); | 1020 __ bne(&next_test); |
1064 __ Drop(1); // Switch value is no longer needed. | 1021 __ Drop(1); // Switch value is no longer needed. |
1065 __ b(clause->body_target()); | 1022 __ b(clause->body_target()); |
1066 } | 1023 } |
1067 | 1024 |
1068 // Discard the test value and jump to the default if present, otherwise to | 1025 // Discard the test value and jump to the default if present, otherwise to |
1069 // the end of the statement. | 1026 // the end of the statement. |
1070 __ bind(&next_test); | 1027 __ bind(&next_test); |
1071 __ Drop(1); // Switch value is no longer needed. | 1028 __ Drop(1); // Switch value is no longer needed. |
1072 if (default_clause == NULL) { | 1029 if (default_clause == NULL) { |
1073 __ b(nested_statement.break_label()); | 1030 __ b(nested_statement.break_label()); |
(...skipping 21 matching lines...) Expand all Loading... |
1095 SetStatementPosition(stmt); | 1052 SetStatementPosition(stmt); |
1096 | 1053 |
1097 Label loop, exit; | 1054 Label loop, exit; |
1098 ForIn loop_statement(this, stmt); | 1055 ForIn loop_statement(this, stmt); |
1099 increment_loop_depth(); | 1056 increment_loop_depth(); |
1100 | 1057 |
1101 // Get the object to enumerate over. If the object is null or undefined, skip | 1058 // Get the object to enumerate over. If the object is null or undefined, skip |
1102 // over the loop. See ECMA-262 version 5, section 12.6.4. | 1059 // over the loop. See ECMA-262 version 5, section 12.6.4. |
1103 VisitForAccumulatorValue(stmt->enumerable()); | 1060 VisitForAccumulatorValue(stmt->enumerable()); |
1104 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 1061 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
1105 __ cmp(r0, ip); | 1062 __ cmp(r3, ip); |
1106 __ b(eq, &exit); | 1063 __ beq(&exit); |
1107 Register null_value = r5; | 1064 Register null_value = r7; |
1108 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 1065 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
1109 __ cmp(r0, null_value); | 1066 __ cmp(r3, null_value); |
1110 __ b(eq, &exit); | 1067 __ beq(&exit); |
1111 | 1068 |
1112 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 1069 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
1113 | 1070 |
1114 // Convert the object to a JS object. | 1071 // Convert the object to a JS object. |
1115 Label convert, done_convert; | 1072 Label convert, done_convert; |
1116 __ JumpIfSmi(r0, &convert); | 1073 __ JumpIfSmi(r3, &convert); |
1117 __ CompareObjectType(r0, r1, r1, FIRST_SPEC_OBJECT_TYPE); | 1074 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); |
1118 __ b(ge, &done_convert); | 1075 __ bge(&done_convert); |
1119 __ bind(&convert); | 1076 __ bind(&convert); |
1120 __ push(r0); | 1077 __ push(r3); |
1121 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 1078 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
1122 __ bind(&done_convert); | 1079 __ bind(&done_convert); |
1123 __ push(r0); | 1080 __ push(r3); |
1124 | 1081 |
1125 // Check for proxies. | 1082 // Check for proxies. |
1126 Label call_runtime; | 1083 Label call_runtime; |
1127 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | 1084 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
1128 __ CompareObjectType(r0, r1, r1, LAST_JS_PROXY_TYPE); | 1085 __ CompareObjectType(r3, r4, r4, LAST_JS_PROXY_TYPE); |
1129 __ b(le, &call_runtime); | 1086 __ ble(&call_runtime); |
1130 | 1087 |
1131 // Check cache validity in generated code. This is a fast case for | 1088 // Check cache validity in generated code. This is a fast case for |
1132 // the JSObject::IsSimpleEnum cache validity checks. If we cannot | 1089 // the JSObject::IsSimpleEnum cache validity checks. If we cannot |
1133 // guarantee cache validity, call the runtime system to check cache | 1090 // guarantee cache validity, call the runtime system to check cache |
1134 // validity or get the property names in a fixed array. | 1091 // validity or get the property names in a fixed array. |
1135 __ CheckEnumCache(null_value, &call_runtime); | 1092 __ CheckEnumCache(null_value, &call_runtime); |
1136 | 1093 |
1137 // The enum cache is valid. Load the map of the object being | 1094 // The enum cache is valid. Load the map of the object being |
1138 // iterated over and use the cache for the iteration. | 1095 // iterated over and use the cache for the iteration. |
1139 Label use_cache; | 1096 Label use_cache; |
1140 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 1097 __ LoadP(r3, FieldMemOperand(r3, HeapObject::kMapOffset)); |
1141 __ b(&use_cache); | 1098 __ b(&use_cache); |
1142 | 1099 |
1143 // Get the set of properties to enumerate. | 1100 // Get the set of properties to enumerate. |
1144 __ bind(&call_runtime); | 1101 __ bind(&call_runtime); |
1145 __ push(r0); // Duplicate the enumerable object on the stack. | 1102 __ push(r3); // Duplicate the enumerable object on the stack. |
1146 __ CallRuntime(Runtime::kGetPropertyNamesFast, 1); | 1103 __ CallRuntime(Runtime::kGetPropertyNamesFast, 1); |
1147 | 1104 |
1148 // If we got a map from the runtime call, we can do a fast | 1105 // If we got a map from the runtime call, we can do a fast |
1149 // modification check. Otherwise, we got a fixed array, and we have | 1106 // modification check. Otherwise, we got a fixed array, and we have |
1150 // to do a slow check. | 1107 // to do a slow check. |
1151 Label fixed_array; | 1108 Label fixed_array; |
1152 __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); | 1109 __ LoadP(r5, FieldMemOperand(r3, HeapObject::kMapOffset)); |
1153 __ LoadRoot(ip, Heap::kMetaMapRootIndex); | 1110 __ LoadRoot(ip, Heap::kMetaMapRootIndex); |
1154 __ cmp(r2, ip); | 1111 __ cmp(r5, ip); |
1155 __ b(ne, &fixed_array); | 1112 __ bne(&fixed_array); |
1156 | 1113 |
1157 // We got a map in register r0. Get the enumeration cache from it. | 1114 // We got a map in register r3. Get the enumeration cache from it. |
1158 Label no_descriptors; | 1115 Label no_descriptors; |
1159 __ bind(&use_cache); | 1116 __ bind(&use_cache); |
1160 | 1117 |
1161 __ EnumLength(r1, r0); | 1118 __ EnumLength(r4, r3); |
1162 __ cmp(r1, Operand(Smi::FromInt(0))); | 1119 __ CmpSmiLiteral(r4, Smi::FromInt(0), r0); |
1163 __ b(eq, &no_descriptors); | 1120 __ beq(&no_descriptors); |
1164 | 1121 |
1165 __ LoadInstanceDescriptors(r0, r2); | 1122 __ LoadInstanceDescriptors(r3, r5); |
1166 __ ldr(r2, FieldMemOperand(r2, DescriptorArray::kEnumCacheOffset)); | 1123 __ LoadP(r5, FieldMemOperand(r5, DescriptorArray::kEnumCacheOffset)); |
1167 __ ldr(r2, FieldMemOperand(r2, DescriptorArray::kEnumCacheBridgeCacheOffset)); | 1124 __ LoadP(r5, |
| 1125 FieldMemOperand(r5, DescriptorArray::kEnumCacheBridgeCacheOffset)); |
1168 | 1126 |
1169 // Set up the four remaining stack slots. | 1127 // Set up the four remaining stack slots. |
1170 __ push(r0); // Map. | 1128 __ push(r3); // Map. |
1171 __ mov(r0, Operand(Smi::FromInt(0))); | 1129 __ LoadSmiLiteral(r3, Smi::FromInt(0)); |
1172 // Push enumeration cache, enumeration cache length (as smi) and zero. | 1130 // Push enumeration cache, enumeration cache length (as smi) and zero. |
1173 __ Push(r2, r1, r0); | 1131 __ Push(r5, r4, r3); |
1174 __ jmp(&loop); | 1132 __ b(&loop); |
1175 | 1133 |
1176 __ bind(&no_descriptors); | 1134 __ bind(&no_descriptors); |
1177 __ Drop(1); | 1135 __ Drop(1); |
1178 __ jmp(&exit); | 1136 __ b(&exit); |
1179 | 1137 |
1180 // We got a fixed array in register r0. Iterate through that. | 1138 // We got a fixed array in register r3. Iterate through that. |
1181 Label non_proxy; | 1139 Label non_proxy; |
1182 __ bind(&fixed_array); | 1140 __ bind(&fixed_array); |
1183 | 1141 |
1184 __ Move(r1, FeedbackVector()); | 1142 __ Move(r4, FeedbackVector()); |
1185 __ mov(r2, Operand(TypeFeedbackInfo::MegamorphicSentinel(isolate()))); | 1143 __ mov(r5, Operand(TypeFeedbackInfo::MegamorphicSentinel(isolate()))); |
1186 __ str(r2, FieldMemOperand(r1, FixedArray::OffsetOfElementAt(slot))); | 1144 __ StoreP(r5, FieldMemOperand(r4, FixedArray::OffsetOfElementAt(slot)), r0); |
1187 | 1145 |
1188 __ mov(r1, Operand(Smi::FromInt(1))); // Smi indicates slow check | 1146 __ LoadSmiLiteral(r4, Smi::FromInt(1)); // Smi indicates slow check |
1189 __ ldr(r2, MemOperand(sp, 0 * kPointerSize)); // Get enumerated object | 1147 __ LoadP(r5, MemOperand(sp, 0 * kPointerSize)); // Get enumerated object |
1190 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | 1148 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
1191 __ CompareObjectType(r2, r3, r3, LAST_JS_PROXY_TYPE); | 1149 __ CompareObjectType(r5, r6, r6, LAST_JS_PROXY_TYPE); |
1192 __ b(gt, &non_proxy); | 1150 __ bgt(&non_proxy); |
1193 __ mov(r1, Operand(Smi::FromInt(0))); // Zero indicates proxy | 1151 __ LoadSmiLiteral(r4, Smi::FromInt(0)); // Zero indicates proxy |
1194 __ bind(&non_proxy); | 1152 __ bind(&non_proxy); |
1195 __ Push(r1, r0); // Smi and array | 1153 __ Push(r4, r3); // Smi and array |
1196 __ ldr(r1, FieldMemOperand(r0, FixedArray::kLengthOffset)); | 1154 __ LoadP(r4, FieldMemOperand(r3, FixedArray::kLengthOffset)); |
1197 __ mov(r0, Operand(Smi::FromInt(0))); | 1155 __ LoadSmiLiteral(r3, Smi::FromInt(0)); |
1198 __ Push(r1, r0); // Fixed array length (as smi) and initial index. | 1156 __ Push(r4, r3); // Fixed array length (as smi) and initial index. |
1199 | 1157 |
1200 // Generate code for doing the condition check. | 1158 // Generate code for doing the condition check. |
1201 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | 1159 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); |
1202 __ bind(&loop); | 1160 __ bind(&loop); |
1203 // Load the current count to r0, load the length to r1. | 1161 // Load the current count to r3, load the length to r4. |
1204 __ Ldrd(r0, r1, MemOperand(sp, 0 * kPointerSize)); | 1162 __ LoadP(r3, MemOperand(sp, 0 * kPointerSize)); |
1205 __ cmp(r0, r1); // Compare to the array length. | 1163 __ LoadP(r4, MemOperand(sp, 1 * kPointerSize)); |
1206 __ b(hs, loop_statement.break_label()); | 1164 __ cmpl(r3, r4); // Compare to the array length. |
| 1165 __ bge(loop_statement.break_label()); |
1207 | 1166 |
1208 // Get the current entry of the array into register r3. | 1167 // Get the current entry of the array into register r6. |
1209 __ ldr(r2, MemOperand(sp, 2 * kPointerSize)); | 1168 __ LoadP(r5, MemOperand(sp, 2 * kPointerSize)); |
1210 __ add(r2, r2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 1169 __ addi(r5, r5, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
1211 __ ldr(r3, MemOperand::PointerAddressFromSmiKey(r2, r0)); | 1170 __ SmiToPtrArrayOffset(r6, r3); |
| 1171 __ LoadPX(r6, MemOperand(r6, r5)); |
1212 | 1172 |
1213 // Get the expected map from the stack or a smi in the | 1173 // Get the expected map from the stack or a smi in the |
1214 // permanent slow case into register r2. | 1174 // permanent slow case into register r5. |
1215 __ ldr(r2, MemOperand(sp, 3 * kPointerSize)); | 1175 __ LoadP(r5, MemOperand(sp, 3 * kPointerSize)); |
1216 | 1176 |
1217 // Check if the expected map still matches that of the enumerable. | 1177 // Check if the expected map still matches that of the enumerable. |
1218 // If not, we may have to filter the key. | 1178 // If not, we may have to filter the key. |
1219 Label update_each; | 1179 Label update_each; |
1220 __ ldr(r1, MemOperand(sp, 4 * kPointerSize)); | 1180 __ LoadP(r4, MemOperand(sp, 4 * kPointerSize)); |
1221 __ ldr(r4, FieldMemOperand(r1, HeapObject::kMapOffset)); | 1181 __ LoadP(r7, FieldMemOperand(r4, HeapObject::kMapOffset)); |
1222 __ cmp(r4, Operand(r2)); | 1182 __ cmp(r7, r5); |
1223 __ b(eq, &update_each); | 1183 __ beq(&update_each); |
1224 | 1184 |
1225 // For proxies, no filtering is done. | 1185 // For proxies, no filtering is done. |
1226 // TODO(rossberg): What if only a prototype is a proxy? Not specified yet. | 1186 // TODO(rossberg): What if only a prototype is a proxy? Not specified yet. |
1227 __ cmp(r2, Operand(Smi::FromInt(0))); | 1187 __ CmpSmiLiteral(r5, Smi::FromInt(0), r0); |
1228 __ b(eq, &update_each); | 1188 __ beq(&update_each); |
1229 | 1189 |
1230 // Convert the entry to a string or (smi) 0 if it isn't a property | 1190 // Convert the entry to a string or (smi) 0 if it isn't a property |
1231 // any more. If the property has been removed while iterating, we | 1191 // any more. If the property has been removed while iterating, we |
1232 // just skip it. | 1192 // just skip it. |
1233 __ push(r1); // Enumerable. | 1193 __ Push(r4, r6); // Enumerable and current entry. |
1234 __ push(r3); // Current entry. | |
1235 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); | 1194 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); |
1236 __ mov(r3, Operand(r0), SetCC); | 1195 __ mr(r6, r3); |
1237 __ b(eq, loop_statement.continue_label()); | 1196 __ cmpi(r6, Operand::Zero()); |
| 1197 __ beq(loop_statement.continue_label()); |
1238 | 1198 |
1239 // Update the 'each' property or variable from the possibly filtered | 1199 // Update the 'each' property or variable from the possibly filtered |
1240 // entry in register r3. | 1200 // entry in register r6. |
1241 __ bind(&update_each); | 1201 __ bind(&update_each); |
1242 __ mov(result_register(), r3); | 1202 __ mr(result_register(), r6); |
1243 // Perform the assignment as if via '='. | 1203 // Perform the assignment as if via '='. |
1244 { EffectContext context(this); | 1204 { |
| 1205 EffectContext context(this); |
1245 EmitAssignment(stmt->each()); | 1206 EmitAssignment(stmt->each()); |
1246 } | 1207 } |
1247 | 1208 |
1248 // Generate code for the body of the loop. | 1209 // Generate code for the body of the loop. |
1249 Visit(stmt->body()); | 1210 Visit(stmt->body()); |
1250 | 1211 |
1251 // Generate code for the going to the next element by incrementing | 1212 // Generate code for the going to the next element by incrementing |
1252 // the index (smi) stored on top of the stack. | 1213 // the index (smi) stored on top of the stack. |
1253 __ bind(loop_statement.continue_label()); | 1214 __ bind(loop_statement.continue_label()); |
1254 __ pop(r0); | 1215 __ pop(r3); |
1255 __ add(r0, r0, Operand(Smi::FromInt(1))); | 1216 __ AddSmiLiteral(r3, r3, Smi::FromInt(1), r0); |
1256 __ push(r0); | 1217 __ push(r3); |
1257 | 1218 |
1258 EmitBackEdgeBookkeeping(stmt, &loop); | 1219 EmitBackEdgeBookkeeping(stmt, &loop); |
1259 __ b(&loop); | 1220 __ b(&loop); |
1260 | 1221 |
1261 // Remove the pointers stored on the stack. | 1222 // Remove the pointers stored on the stack. |
1262 __ bind(loop_statement.break_label()); | 1223 __ bind(loop_statement.break_label()); |
1263 __ Drop(5); | 1224 __ Drop(5); |
1264 | 1225 |
1265 // Exit and decrement the loop depth. | 1226 // Exit and decrement the loop depth. |
1266 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1227 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
(...skipping 13 matching lines...) Expand all Loading... |
1280 VisitForEffect(stmt->assign_iterator()); | 1241 VisitForEffect(stmt->assign_iterator()); |
1281 | 1242 |
1282 // Loop entry. | 1243 // Loop entry. |
1283 __ bind(loop_statement.continue_label()); | 1244 __ bind(loop_statement.continue_label()); |
1284 | 1245 |
1285 // result = iterator.next() | 1246 // result = iterator.next() |
1286 VisitForEffect(stmt->next_result()); | 1247 VisitForEffect(stmt->next_result()); |
1287 | 1248 |
1288 // if (result.done) break; | 1249 // if (result.done) break; |
1289 Label result_not_done; | 1250 Label result_not_done; |
1290 VisitForControl(stmt->result_done(), | 1251 VisitForControl(stmt->result_done(), loop_statement.break_label(), |
1291 loop_statement.break_label(), | 1252 &result_not_done, &result_not_done); |
1292 &result_not_done, | |
1293 &result_not_done); | |
1294 __ bind(&result_not_done); | 1253 __ bind(&result_not_done); |
1295 | 1254 |
1296 // each = result.value | 1255 // each = result.value |
1297 VisitForEffect(stmt->assign_each()); | 1256 VisitForEffect(stmt->assign_each()); |
1298 | 1257 |
1299 // Generate code for the body of the loop. | 1258 // Generate code for the body of the loop. |
1300 Visit(stmt->body()); | 1259 Visit(stmt->body()); |
1301 | 1260 |
1302 // Check stack before looping. | 1261 // Check stack before looping. |
1303 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); | 1262 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); |
1304 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); | 1263 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); |
1305 __ jmp(loop_statement.continue_label()); | 1264 __ b(loop_statement.continue_label()); |
1306 | 1265 |
1307 // Exit and decrement the loop depth. | 1266 // Exit and decrement the loop depth. |
1308 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1267 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1309 __ bind(loop_statement.break_label()); | 1268 __ bind(loop_statement.break_label()); |
1310 decrement_loop_depth(); | 1269 decrement_loop_depth(); |
1311 } | 1270 } |
1312 | 1271 |
1313 | 1272 |
1314 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1273 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1315 bool pretenure) { | 1274 bool pretenure) { |
1316 // Use the fast case closure allocation code that allocates in new | 1275 // Use the fast case closure allocation code that allocates in new |
1317 // space for nested functions that don't need literals cloning. If | 1276 // space for nested functions that don't need literals cloning. If |
1318 // we're running with the --always-opt or the --prepare-always-opt | 1277 // we're running with the --always-opt or the --prepare-always-opt |
1319 // flag, we need to use the runtime function so that the new function | 1278 // flag, we need to use the runtime function so that the new function |
1320 // we are creating here gets a chance to have its code optimized and | 1279 // we are creating here gets a chance to have its code optimized and |
1321 // doesn't just get a copy of the existing unoptimized code. | 1280 // doesn't just get a copy of the existing unoptimized code. |
1322 if (!FLAG_always_opt && | 1281 if (!FLAG_always_opt && !FLAG_prepare_always_opt && !pretenure && |
1323 !FLAG_prepare_always_opt && | 1282 scope()->is_function_scope() && info->num_literals() == 0) { |
1324 !pretenure && | 1283 FastNewClosureStub stub(isolate(), info->strict_mode(), |
1325 scope()->is_function_scope() && | |
1326 info->num_literals() == 0) { | |
1327 FastNewClosureStub stub(isolate(), | |
1328 info->strict_mode(), | |
1329 info->is_generator()); | 1284 info->is_generator()); |
1330 __ mov(r2, Operand(info)); | 1285 __ mov(r5, Operand(info)); |
1331 __ CallStub(&stub); | 1286 __ CallStub(&stub); |
1332 } else { | 1287 } else { |
1333 __ mov(r0, Operand(info)); | 1288 __ mov(r3, Operand(info)); |
1334 __ LoadRoot(r1, pretenure ? Heap::kTrueValueRootIndex | 1289 __ LoadRoot( |
1335 : Heap::kFalseValueRootIndex); | 1290 r4, pretenure ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex); |
1336 __ Push(cp, r0, r1); | 1291 __ Push(cp, r3, r4); |
1337 __ CallRuntime(Runtime::kNewClosure, 3); | 1292 __ CallRuntime(Runtime::kNewClosure, 3); |
1338 } | 1293 } |
1339 context()->Plug(r0); | 1294 context()->Plug(r3); |
1340 } | 1295 } |
1341 | 1296 |
1342 | 1297 |
1343 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 1298 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
1344 Comment cmnt(masm_, "[ VariableProxy"); | 1299 Comment cmnt(masm_, "[ VariableProxy"); |
1345 EmitVariableLoad(expr); | 1300 EmitVariableLoad(expr); |
1346 } | 1301 } |
1347 | 1302 |
1348 | 1303 |
1349 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, | 1304 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, |
1350 TypeofState typeof_state, | 1305 TypeofState typeof_state, |
1351 Label* slow) { | 1306 Label* slow) { |
1352 Register current = cp; | 1307 Register current = cp; |
1353 Register next = r1; | 1308 Register next = r4; |
1354 Register temp = r2; | 1309 Register temp = r5; |
1355 | 1310 |
1356 Scope* s = scope(); | 1311 Scope* s = scope(); |
1357 while (s != NULL) { | 1312 while (s != NULL) { |
1358 if (s->num_heap_slots() > 0) { | 1313 if (s->num_heap_slots() > 0) { |
1359 if (s->calls_sloppy_eval()) { | 1314 if (s->calls_sloppy_eval()) { |
1360 // Check that extension is NULL. | 1315 // Check that extension is NULL. |
1361 __ ldr(temp, ContextOperand(current, Context::EXTENSION_INDEX)); | 1316 __ LoadP(temp, ContextOperand(current, Context::EXTENSION_INDEX)); |
1362 __ tst(temp, temp); | 1317 __ cmpi(temp, Operand::Zero()); |
1363 __ b(ne, slow); | 1318 __ bne(slow); |
1364 } | 1319 } |
1365 // Load next context in chain. | 1320 // Load next context in chain. |
1366 __ ldr(next, ContextOperand(current, Context::PREVIOUS_INDEX)); | 1321 __ LoadP(next, ContextOperand(current, Context::PREVIOUS_INDEX)); |
1367 // Walk the rest of the chain without clobbering cp. | 1322 // Walk the rest of the chain without clobbering cp. |
1368 current = next; | 1323 current = next; |
1369 } | 1324 } |
1370 // If no outer scope calls eval, we do not need to check more | 1325 // If no outer scope calls eval, we do not need to check more |
1371 // context extensions. | 1326 // context extensions. |
1372 if (!s->outer_scope_calls_sloppy_eval() || s->is_eval_scope()) break; | 1327 if (!s->outer_scope_calls_sloppy_eval() || s->is_eval_scope()) break; |
1373 s = s->outer_scope(); | 1328 s = s->outer_scope(); |
1374 } | 1329 } |
1375 | 1330 |
1376 if (s->is_eval_scope()) { | 1331 if (s->is_eval_scope()) { |
1377 Label loop, fast; | 1332 Label loop, fast; |
1378 if (!current.is(next)) { | 1333 if (!current.is(next)) { |
1379 __ Move(next, current); | 1334 __ Move(next, current); |
1380 } | 1335 } |
1381 __ bind(&loop); | 1336 __ bind(&loop); |
1382 // Terminate at native context. | 1337 // Terminate at native context. |
1383 __ ldr(temp, FieldMemOperand(next, HeapObject::kMapOffset)); | 1338 __ LoadP(temp, FieldMemOperand(next, HeapObject::kMapOffset)); |
1384 __ LoadRoot(ip, Heap::kNativeContextMapRootIndex); | 1339 __ LoadRoot(ip, Heap::kNativeContextMapRootIndex); |
1385 __ cmp(temp, ip); | 1340 __ cmp(temp, ip); |
1386 __ b(eq, &fast); | 1341 __ beq(&fast); |
1387 // Check that extension is NULL. | 1342 // Check that extension is NULL. |
1388 __ ldr(temp, ContextOperand(next, Context::EXTENSION_INDEX)); | 1343 __ LoadP(temp, ContextOperand(next, Context::EXTENSION_INDEX)); |
1389 __ tst(temp, temp); | 1344 __ cmpi(temp, Operand::Zero()); |
1390 __ b(ne, slow); | 1345 __ bne(slow); |
1391 // Load next context in chain. | 1346 // Load next context in chain. |
1392 __ ldr(next, ContextOperand(next, Context::PREVIOUS_INDEX)); | 1347 __ LoadP(next, ContextOperand(next, Context::PREVIOUS_INDEX)); |
1393 __ b(&loop); | 1348 __ b(&loop); |
1394 __ bind(&fast); | 1349 __ bind(&fast); |
1395 } | 1350 } |
1396 | 1351 |
1397 __ ldr(LoadIC::ReceiverRegister(), GlobalObjectOperand()); | 1352 __ LoadP(LoadIC::ReceiverRegister(), GlobalObjectOperand()); |
1398 __ mov(LoadIC::NameRegister(), Operand(proxy->var()->name())); | 1353 __ mov(LoadIC::NameRegister(), Operand(proxy->var()->name())); |
1399 if (FLAG_vector_ics) { | 1354 if (FLAG_vector_ics) { |
1400 __ mov(LoadIC::SlotRegister(), | 1355 __ mov(LoadIC::SlotRegister(), |
1401 Operand(Smi::FromInt(proxy->VariableFeedbackSlot()))); | 1356 Operand(Smi::FromInt(proxy->VariableFeedbackSlot()))); |
1402 } | 1357 } |
1403 | 1358 ContextualMode mode = |
1404 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) | 1359 (typeof_state == INSIDE_TYPEOF) ? NOT_CONTEXTUAL : CONTEXTUAL; |
1405 ? NOT_CONTEXTUAL | |
1406 : CONTEXTUAL; | |
1407 CallLoadIC(mode); | 1360 CallLoadIC(mode); |
1408 } | 1361 } |
1409 | 1362 |
1410 | 1363 |
1411 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, | 1364 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, |
1412 Label* slow) { | 1365 Label* slow) { |
1413 DCHECK(var->IsContextSlot()); | 1366 DCHECK(var->IsContextSlot()); |
1414 Register context = cp; | 1367 Register context = cp; |
1415 Register next = r3; | 1368 Register next = r6; |
1416 Register temp = r4; | 1369 Register temp = r7; |
1417 | 1370 |
1418 for (Scope* s = scope(); s != var->scope(); s = s->outer_scope()) { | 1371 for (Scope* s = scope(); s != var->scope(); s = s->outer_scope()) { |
1419 if (s->num_heap_slots() > 0) { | 1372 if (s->num_heap_slots() > 0) { |
1420 if (s->calls_sloppy_eval()) { | 1373 if (s->calls_sloppy_eval()) { |
1421 // Check that extension is NULL. | 1374 // Check that extension is NULL. |
1422 __ ldr(temp, ContextOperand(context, Context::EXTENSION_INDEX)); | 1375 __ LoadP(temp, ContextOperand(context, Context::EXTENSION_INDEX)); |
1423 __ tst(temp, temp); | 1376 __ cmpi(temp, Operand::Zero()); |
1424 __ b(ne, slow); | 1377 __ bne(slow); |
1425 } | 1378 } |
1426 __ ldr(next, ContextOperand(context, Context::PREVIOUS_INDEX)); | 1379 __ LoadP(next, ContextOperand(context, Context::PREVIOUS_INDEX)); |
1427 // Walk the rest of the chain without clobbering cp. | 1380 // Walk the rest of the chain without clobbering cp. |
1428 context = next; | 1381 context = next; |
1429 } | 1382 } |
1430 } | 1383 } |
1431 // Check that last extension is NULL. | 1384 // Check that last extension is NULL. |
1432 __ ldr(temp, ContextOperand(context, Context::EXTENSION_INDEX)); | 1385 __ LoadP(temp, ContextOperand(context, Context::EXTENSION_INDEX)); |
1433 __ tst(temp, temp); | 1386 __ cmpi(temp, Operand::Zero()); |
1434 __ b(ne, slow); | 1387 __ bne(slow); |
1435 | 1388 |
1436 // This function is used only for loads, not stores, so it's safe to | 1389 // This function is used only for loads, not stores, so it's safe to |
1437 // return an cp-based operand (the write barrier cannot be allowed to | 1390 // return an cp-based operand (the write barrier cannot be allowed to |
1438 // destroy the cp register). | 1391 // destroy the cp register). |
1439 return ContextOperand(context, var->index()); | 1392 return ContextOperand(context, var->index()); |
1440 } | 1393 } |
1441 | 1394 |
1442 | 1395 |
1443 void FullCodeGenerator::EmitDynamicLookupFastCase(VariableProxy* proxy, | 1396 void FullCodeGenerator::EmitDynamicLookupFastCase(VariableProxy* proxy, |
1444 TypeofState typeof_state, | 1397 TypeofState typeof_state, |
1445 Label* slow, | 1398 Label* slow, Label* done) { |
1446 Label* done) { | |
1447 // Generate fast-case code for variables that might be shadowed by | 1399 // Generate fast-case code for variables that might be shadowed by |
1448 // eval-introduced variables. Eval is used a lot without | 1400 // eval-introduced variables. Eval is used a lot without |
1449 // introducing variables. In those cases, we do not want to | 1401 // introducing variables. In those cases, we do not want to |
1450 // perform a runtime call for all variables in the scope | 1402 // perform a runtime call for all variables in the scope |
1451 // containing the eval. | 1403 // containing the eval. |
1452 Variable* var = proxy->var(); | 1404 Variable* var = proxy->var(); |
1453 if (var->mode() == DYNAMIC_GLOBAL) { | 1405 if (var->mode() == DYNAMIC_GLOBAL) { |
1454 EmitLoadGlobalCheckExtensions(proxy, typeof_state, slow); | 1406 EmitLoadGlobalCheckExtensions(proxy, typeof_state, slow); |
1455 __ jmp(done); | 1407 __ b(done); |
1456 } else if (var->mode() == DYNAMIC_LOCAL) { | 1408 } else if (var->mode() == DYNAMIC_LOCAL) { |
1457 Variable* local = var->local_if_not_shadowed(); | 1409 Variable* local = var->local_if_not_shadowed(); |
1458 __ ldr(r0, ContextSlotOperandCheckExtensions(local, slow)); | 1410 __ LoadP(r3, ContextSlotOperandCheckExtensions(local, slow)); |
1459 if (local->mode() == LET || local->mode() == CONST || | 1411 if (local->mode() == LET || local->mode() == CONST || |
1460 local->mode() == CONST_LEGACY) { | 1412 local->mode() == CONST_LEGACY) { |
1461 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 1413 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 1414 __ bne(done); |
1462 if (local->mode() == CONST_LEGACY) { | 1415 if (local->mode() == CONST_LEGACY) { |
1463 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); | 1416 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
1464 } else { // LET || CONST | 1417 } else { // LET || CONST |
1465 __ b(ne, done); | 1418 __ mov(r3, Operand(var->name())); |
1466 __ mov(r0, Operand(var->name())); | 1419 __ push(r3); |
1467 __ push(r0); | |
1468 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 1420 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
1469 } | 1421 } |
1470 } | 1422 } |
1471 __ jmp(done); | 1423 __ b(done); |
1472 } | 1424 } |
1473 } | 1425 } |
1474 | 1426 |
1475 | 1427 |
1476 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { | 1428 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { |
1477 // Record position before possible IC call. | 1429 // Record position before possible IC call. |
1478 SetSourcePosition(proxy->position()); | 1430 SetSourcePosition(proxy->position()); |
1479 Variable* var = proxy->var(); | 1431 Variable* var = proxy->var(); |
1480 | 1432 |
1481 // Three cases: global variables, lookup variables, and all other types of | 1433 // Three cases: global variables, lookup variables, and all other types of |
1482 // variables. | 1434 // variables. |
1483 switch (var->location()) { | 1435 switch (var->location()) { |
1484 case Variable::UNALLOCATED: { | 1436 case Variable::UNALLOCATED: { |
1485 Comment cmnt(masm_, "[ Global variable"); | 1437 Comment cmnt(masm_, "[ Global variable"); |
1486 __ ldr(LoadIC::ReceiverRegister(), GlobalObjectOperand()); | 1438 // Use inline caching. Variable name is passed in r5 and the global |
| 1439 // object (receiver) in r3. |
| 1440 __ LoadP(LoadIC::ReceiverRegister(), GlobalObjectOperand()); |
1487 __ mov(LoadIC::NameRegister(), Operand(var->name())); | 1441 __ mov(LoadIC::NameRegister(), Operand(var->name())); |
1488 if (FLAG_vector_ics) { | 1442 if (FLAG_vector_ics) { |
1489 __ mov(LoadIC::SlotRegister(), | 1443 __ mov(LoadIC::SlotRegister(), |
1490 Operand(Smi::FromInt(proxy->VariableFeedbackSlot()))); | 1444 Operand(Smi::FromInt(proxy->VariableFeedbackSlot()))); |
1491 } | 1445 } |
1492 CallLoadIC(CONTEXTUAL); | 1446 CallLoadIC(CONTEXTUAL); |
1493 context()->Plug(r0); | 1447 context()->Plug(r3); |
1494 break; | 1448 break; |
1495 } | 1449 } |
1496 | 1450 |
1497 case Variable::PARAMETER: | 1451 case Variable::PARAMETER: |
1498 case Variable::LOCAL: | 1452 case Variable::LOCAL: |
1499 case Variable::CONTEXT: { | 1453 case Variable::CONTEXT: { |
1500 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1454 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
1501 : "[ Stack variable"); | 1455 : "[ Stack variable"); |
1502 if (var->binding_needs_init()) { | 1456 if (var->binding_needs_init()) { |
1503 // var->scope() may be NULL when the proxy is located in eval code and | 1457 // var->scope() may be NULL when the proxy is located in eval code and |
(...skipping 20 matching lines...) Expand all Loading... |
1524 // function() { f(); let x = 1; function f() { x = 2; } } | 1478 // function() { f(); let x = 1; function f() { x = 2; } } |
1525 // | 1479 // |
1526 bool skip_init_check; | 1480 bool skip_init_check; |
1527 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { | 1481 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { |
1528 skip_init_check = false; | 1482 skip_init_check = false; |
1529 } else { | 1483 } else { |
1530 // Check that we always have valid source position. | 1484 // Check that we always have valid source position. |
1531 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); | 1485 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); |
1532 DCHECK(proxy->position() != RelocInfo::kNoPosition); | 1486 DCHECK(proxy->position() != RelocInfo::kNoPosition); |
1533 skip_init_check = var->mode() != CONST_LEGACY && | 1487 skip_init_check = var->mode() != CONST_LEGACY && |
1534 var->initializer_position() < proxy->position(); | 1488 var->initializer_position() < proxy->position(); |
1535 } | 1489 } |
1536 | 1490 |
1537 if (!skip_init_check) { | 1491 if (!skip_init_check) { |
| 1492 Label done; |
1538 // Let and const need a read barrier. | 1493 // Let and const need a read barrier. |
1539 GetVar(r0, var); | 1494 GetVar(r3, var); |
1540 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 1495 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 1496 __ bne(&done); |
1541 if (var->mode() == LET || var->mode() == CONST) { | 1497 if (var->mode() == LET || var->mode() == CONST) { |
1542 // Throw a reference error when using an uninitialized let/const | 1498 // Throw a reference error when using an uninitialized let/const |
1543 // binding in harmony mode. | 1499 // binding in harmony mode. |
1544 Label done; | 1500 __ mov(r3, Operand(var->name())); |
1545 __ b(ne, &done); | 1501 __ push(r3); |
1546 __ mov(r0, Operand(var->name())); | |
1547 __ push(r0); | |
1548 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 1502 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
1549 __ bind(&done); | |
1550 } else { | 1503 } else { |
1551 // Uninitalized const bindings outside of harmony mode are unholed. | 1504 // Uninitalized const bindings outside of harmony mode are unholed. |
1552 DCHECK(var->mode() == CONST_LEGACY); | 1505 DCHECK(var->mode() == CONST_LEGACY); |
1553 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); | 1506 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
1554 } | 1507 } |
1555 context()->Plug(r0); | 1508 __ bind(&done); |
| 1509 context()->Plug(r3); |
1556 break; | 1510 break; |
1557 } | 1511 } |
1558 } | 1512 } |
1559 context()->Plug(var); | 1513 context()->Plug(var); |
1560 break; | 1514 break; |
1561 } | 1515 } |
1562 | 1516 |
1563 case Variable::LOOKUP: { | 1517 case Variable::LOOKUP: { |
1564 Comment cmnt(masm_, "[ Lookup variable"); | 1518 Comment cmnt(masm_, "[ Lookup variable"); |
1565 Label done, slow; | 1519 Label done, slow; |
1566 // Generate code for loading from variables potentially shadowed | 1520 // Generate code for loading from variables potentially shadowed |
1567 // by eval-introduced variables. | 1521 // by eval-introduced variables. |
1568 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); | 1522 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); |
1569 __ bind(&slow); | 1523 __ bind(&slow); |
1570 __ mov(r1, Operand(var->name())); | 1524 __ mov(r4, Operand(var->name())); |
1571 __ Push(cp, r1); // Context and name. | 1525 __ Push(cp, r4); // Context and name. |
1572 __ CallRuntime(Runtime::kLoadLookupSlot, 2); | 1526 __ CallRuntime(Runtime::kLoadLookupSlot, 2); |
1573 __ bind(&done); | 1527 __ bind(&done); |
1574 context()->Plug(r0); | 1528 context()->Plug(r3); |
1575 } | 1529 } |
1576 } | 1530 } |
1577 } | 1531 } |
1578 | 1532 |
1579 | 1533 |
1580 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 1534 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
1581 Comment cmnt(masm_, "[ RegExpLiteral"); | 1535 Comment cmnt(masm_, "[ RegExpLiteral"); |
1582 Label materialized; | 1536 Label materialized; |
1583 // Registers will be used as follows: | 1537 // Registers will be used as follows: |
1584 // r5 = materialized value (RegExp literal) | 1538 // r8 = materialized value (RegExp literal) |
1585 // r4 = JS function, literals array | 1539 // r7 = JS function, literals array |
1586 // r3 = literal index | 1540 // r6 = literal index |
1587 // r2 = RegExp pattern | 1541 // r5 = RegExp pattern |
1588 // r1 = RegExp flags | 1542 // r4 = RegExp flags |
1589 // r0 = RegExp literal clone | 1543 // r3 = RegExp literal clone |
1590 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1544 __ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1591 __ ldr(r4, FieldMemOperand(r0, JSFunction::kLiteralsOffset)); | 1545 __ LoadP(r7, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); |
1592 int literal_offset = | 1546 int literal_offset = |
1593 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize; | 1547 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize; |
1594 __ ldr(r5, FieldMemOperand(r4, literal_offset)); | 1548 __ LoadP(r8, FieldMemOperand(r7, literal_offset), r0); |
1595 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 1549 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
1596 __ cmp(r5, ip); | 1550 __ cmp(r8, ip); |
1597 __ b(ne, &materialized); | 1551 __ bne(&materialized); |
1598 | 1552 |
1599 // Create regexp literal using runtime function. | 1553 // Create regexp literal using runtime function. |
1600 // Result will be in r0. | 1554 // Result will be in r3. |
1601 __ mov(r3, Operand(Smi::FromInt(expr->literal_index()))); | 1555 __ LoadSmiLiteral(r6, Smi::FromInt(expr->literal_index())); |
1602 __ mov(r2, Operand(expr->pattern())); | 1556 __ mov(r5, Operand(expr->pattern())); |
1603 __ mov(r1, Operand(expr->flags())); | 1557 __ mov(r4, Operand(expr->flags())); |
1604 __ Push(r4, r3, r2, r1); | 1558 __ Push(r7, r6, r5, r4); |
1605 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); | 1559 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); |
1606 __ mov(r5, r0); | 1560 __ mr(r8, r3); |
1607 | 1561 |
1608 __ bind(&materialized); | 1562 __ bind(&materialized); |
1609 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; | 1563 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; |
1610 Label allocated, runtime_allocate; | 1564 Label allocated, runtime_allocate; |
1611 __ Allocate(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT); | 1565 __ Allocate(size, r3, r5, r6, &runtime_allocate, TAG_OBJECT); |
1612 __ jmp(&allocated); | 1566 __ b(&allocated); |
1613 | 1567 |
1614 __ bind(&runtime_allocate); | 1568 __ bind(&runtime_allocate); |
1615 __ mov(r0, Operand(Smi::FromInt(size))); | 1569 __ LoadSmiLiteral(r3, Smi::FromInt(size)); |
1616 __ Push(r5, r0); | 1570 __ Push(r8, r3); |
1617 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 1571 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
1618 __ pop(r5); | 1572 __ pop(r8); |
1619 | 1573 |
1620 __ bind(&allocated); | 1574 __ bind(&allocated); |
1621 // After this, registers are used as follows: | 1575 // After this, registers are used as follows: |
1622 // r0: Newly allocated regexp. | 1576 // r3: Newly allocated regexp. |
1623 // r5: Materialized regexp. | 1577 // r8: Materialized regexp. |
1624 // r2: temp. | 1578 // r5: temp. |
1625 __ CopyFields(r0, r5, d0, size / kPointerSize); | 1579 __ CopyFields(r3, r8, r5.bit(), size / kPointerSize); |
1626 context()->Plug(r0); | 1580 context()->Plug(r3); |
1627 } | 1581 } |
1628 | 1582 |
1629 | 1583 |
1630 void FullCodeGenerator::EmitAccessor(Expression* expression) { | 1584 void FullCodeGenerator::EmitAccessor(Expression* expression) { |
1631 if (expression == NULL) { | 1585 if (expression == NULL) { |
1632 __ LoadRoot(r1, Heap::kNullValueRootIndex); | 1586 __ LoadRoot(r4, Heap::kNullValueRootIndex); |
1633 __ push(r1); | 1587 __ push(r4); |
1634 } else { | 1588 } else { |
1635 VisitForStackValue(expression); | 1589 VisitForStackValue(expression); |
1636 } | 1590 } |
1637 } | 1591 } |
1638 | 1592 |
1639 | 1593 |
1640 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1594 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
1641 Comment cmnt(masm_, "[ ObjectLiteral"); | 1595 Comment cmnt(masm_, "[ ObjectLiteral"); |
1642 | 1596 |
1643 expr->BuildConstantProperties(isolate()); | 1597 expr->BuildConstantProperties(isolate()); |
1644 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1598 Handle<FixedArray> constant_properties = expr->constant_properties(); |
1645 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1599 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1646 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); | 1600 __ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset)); |
1647 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); | 1601 __ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index())); |
1648 __ mov(r1, Operand(constant_properties)); | 1602 __ mov(r4, Operand(constant_properties)); |
1649 int flags = expr->fast_elements() | 1603 int flags = expr->fast_elements() ? ObjectLiteral::kFastElements |
1650 ? ObjectLiteral::kFastElements | 1604 : ObjectLiteral::kNoFlags; |
1651 : ObjectLiteral::kNoFlags; | 1605 flags |= expr->has_function() ? ObjectLiteral::kHasFunction |
1652 flags |= expr->has_function() | 1606 : ObjectLiteral::kNoFlags; |
1653 ? ObjectLiteral::kHasFunction | 1607 __ LoadSmiLiteral(r3, Smi::FromInt(flags)); |
1654 : ObjectLiteral::kNoFlags; | |
1655 __ mov(r0, Operand(Smi::FromInt(flags))); | |
1656 int properties_count = constant_properties->length() / 2; | 1608 int properties_count = constant_properties->length() / 2; |
1657 if (expr->may_store_doubles() || expr->depth() > 1 || | 1609 if (expr->may_store_doubles() || expr->depth() > 1 || |
1658 masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements || | 1610 masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements || |
1659 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | 1611 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
1660 __ Push(r3, r2, r1, r0); | 1612 __ Push(r6, r5, r4, r3); |
1661 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1613 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
1662 } else { | 1614 } else { |
1663 FastCloneShallowObjectStub stub(isolate(), properties_count); | 1615 FastCloneShallowObjectStub stub(isolate(), properties_count); |
1664 __ CallStub(&stub); | 1616 __ CallStub(&stub); |
1665 } | 1617 } |
1666 | 1618 |
1667 // If result_saved is true the result is on top of the stack. If | 1619 // If result_saved is true the result is on top of the stack. If |
1668 // result_saved is false the result is in r0. | 1620 // result_saved is false the result is in r3. |
1669 bool result_saved = false; | 1621 bool result_saved = false; |
1670 | 1622 |
1671 // Mark all computed expressions that are bound to a key that | 1623 // Mark all computed expressions that are bound to a key that |
1672 // is shadowed by a later occurrence of the same key. For the | 1624 // is shadowed by a later occurrence of the same key. For the |
1673 // marked expressions, no store code is emitted. | 1625 // marked expressions, no store code is emitted. |
1674 expr->CalculateEmitStore(zone()); | 1626 expr->CalculateEmitStore(zone()); |
1675 | 1627 |
1676 AccessorTable accessor_table(zone()); | 1628 AccessorTable accessor_table(zone()); |
1677 for (int i = 0; i < expr->properties()->length(); i++) { | 1629 for (int i = 0; i < expr->properties()->length(); i++) { |
1678 ObjectLiteral::Property* property = expr->properties()->at(i); | 1630 ObjectLiteral::Property* property = expr->properties()->at(i); |
1679 if (property->IsCompileTimeValue()) continue; | 1631 if (property->IsCompileTimeValue()) continue; |
1680 | 1632 |
1681 Literal* key = property->key(); | 1633 Literal* key = property->key(); |
1682 Expression* value = property->value(); | 1634 Expression* value = property->value(); |
1683 if (!result_saved) { | 1635 if (!result_saved) { |
1684 __ push(r0); // Save result on stack | 1636 __ push(r3); // Save result on stack |
1685 result_saved = true; | 1637 result_saved = true; |
1686 } | 1638 } |
1687 switch (property->kind()) { | 1639 switch (property->kind()) { |
1688 case ObjectLiteral::Property::CONSTANT: | 1640 case ObjectLiteral::Property::CONSTANT: |
1689 UNREACHABLE(); | 1641 UNREACHABLE(); |
1690 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1642 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1691 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1643 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
1692 // Fall through. | 1644 // Fall through. |
1693 case ObjectLiteral::Property::COMPUTED: | 1645 case ObjectLiteral::Property::COMPUTED: |
1694 if (key->value()->IsInternalizedString()) { | 1646 if (key->value()->IsInternalizedString()) { |
1695 if (property->emit_store()) { | 1647 if (property->emit_store()) { |
1696 VisitForAccumulatorValue(value); | 1648 VisitForAccumulatorValue(value); |
1697 DCHECK(StoreIC::ValueRegister().is(r0)); | 1649 DCHECK(StoreIC::ValueRegister().is(r3)); |
1698 __ mov(StoreIC::NameRegister(), Operand(key->value())); | 1650 __ mov(StoreIC::NameRegister(), Operand(key->value())); |
1699 __ ldr(StoreIC::ReceiverRegister(), MemOperand(sp)); | 1651 __ LoadP(StoreIC::ReceiverRegister(), MemOperand(sp)); |
1700 CallStoreIC(key->LiteralFeedbackId()); | 1652 CallStoreIC(key->LiteralFeedbackId()); |
1701 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1653 PrepareForBailoutForId(key->id(), NO_REGISTERS); |
1702 } else { | 1654 } else { |
1703 VisitForEffect(value); | 1655 VisitForEffect(value); |
1704 } | 1656 } |
1705 break; | 1657 break; |
1706 } | 1658 } |
1707 // Duplicate receiver on stack. | 1659 // Duplicate receiver on stack. |
1708 __ ldr(r0, MemOperand(sp)); | 1660 __ LoadP(r3, MemOperand(sp)); |
1709 __ push(r0); | 1661 __ push(r3); |
1710 VisitForStackValue(key); | 1662 VisitForStackValue(key); |
1711 VisitForStackValue(value); | 1663 VisitForStackValue(value); |
1712 if (property->emit_store()) { | 1664 if (property->emit_store()) { |
1713 __ mov(r0, Operand(Smi::FromInt(SLOPPY))); // PropertyAttributes | 1665 __ LoadSmiLiteral(r3, Smi::FromInt(SLOPPY)); // PropertyAttributes |
1714 __ push(r0); | 1666 __ push(r3); |
1715 __ CallRuntime(Runtime::kSetProperty, 4); | 1667 __ CallRuntime(Runtime::kSetProperty, 4); |
1716 } else { | 1668 } else { |
1717 __ Drop(3); | 1669 __ Drop(3); |
1718 } | 1670 } |
1719 break; | 1671 break; |
1720 case ObjectLiteral::Property::PROTOTYPE: | 1672 case ObjectLiteral::Property::PROTOTYPE: |
1721 // Duplicate receiver on stack. | 1673 // Duplicate receiver on stack. |
1722 __ ldr(r0, MemOperand(sp)); | 1674 __ LoadP(r3, MemOperand(sp)); |
1723 __ push(r0); | 1675 __ push(r3); |
1724 VisitForStackValue(value); | 1676 VisitForStackValue(value); |
1725 if (property->emit_store()) { | 1677 if (property->emit_store()) { |
1726 __ CallRuntime(Runtime::kSetPrototype, 2); | 1678 __ CallRuntime(Runtime::kSetPrototype, 2); |
1727 } else { | 1679 } else { |
1728 __ Drop(2); | 1680 __ Drop(2); |
1729 } | 1681 } |
1730 break; | 1682 break; |
1731 | |
1732 case ObjectLiteral::Property::GETTER: | 1683 case ObjectLiteral::Property::GETTER: |
1733 accessor_table.lookup(key)->second->getter = value; | 1684 accessor_table.lookup(key)->second->getter = value; |
1734 break; | 1685 break; |
1735 case ObjectLiteral::Property::SETTER: | 1686 case ObjectLiteral::Property::SETTER: |
1736 accessor_table.lookup(key)->second->setter = value; | 1687 accessor_table.lookup(key)->second->setter = value; |
1737 break; | 1688 break; |
1738 } | 1689 } |
1739 } | 1690 } |
1740 | 1691 |
1741 // Emit code to define accessors, using only a single call to the runtime for | 1692 // Emit code to define accessors, using only a single call to the runtime for |
1742 // each pair of corresponding getters and setters. | 1693 // each pair of corresponding getters and setters. |
1743 for (AccessorTable::Iterator it = accessor_table.begin(); | 1694 for (AccessorTable::Iterator it = accessor_table.begin(); |
1744 it != accessor_table.end(); | 1695 it != accessor_table.end(); ++it) { |
1745 ++it) { | 1696 __ LoadP(r3, MemOperand(sp)); // Duplicate receiver. |
1746 __ ldr(r0, MemOperand(sp)); // Duplicate receiver. | 1697 __ push(r3); |
1747 __ push(r0); | |
1748 VisitForStackValue(it->first); | 1698 VisitForStackValue(it->first); |
1749 EmitAccessor(it->second->getter); | 1699 EmitAccessor(it->second->getter); |
1750 EmitAccessor(it->second->setter); | 1700 EmitAccessor(it->second->setter); |
1751 __ mov(r0, Operand(Smi::FromInt(NONE))); | 1701 __ LoadSmiLiteral(r3, Smi::FromInt(NONE)); |
1752 __ push(r0); | 1702 __ push(r3); |
1753 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); | 1703 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); |
1754 } | 1704 } |
1755 | 1705 |
1756 if (expr->has_function()) { | 1706 if (expr->has_function()) { |
1757 DCHECK(result_saved); | 1707 DCHECK(result_saved); |
1758 __ ldr(r0, MemOperand(sp)); | 1708 __ LoadP(r3, MemOperand(sp)); |
1759 __ push(r0); | 1709 __ push(r3); |
1760 __ CallRuntime(Runtime::kToFastProperties, 1); | 1710 __ CallRuntime(Runtime::kToFastProperties, 1); |
1761 } | 1711 } |
1762 | 1712 |
1763 if (result_saved) { | 1713 if (result_saved) { |
1764 context()->PlugTOS(); | 1714 context()->PlugTOS(); |
1765 } else { | 1715 } else { |
1766 context()->Plug(r0); | 1716 context()->Plug(r3); |
1767 } | 1717 } |
1768 } | 1718 } |
1769 | 1719 |
1770 | 1720 |
1771 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1721 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
1772 Comment cmnt(masm_, "[ ArrayLiteral"); | 1722 Comment cmnt(masm_, "[ ArrayLiteral"); |
1773 | 1723 |
1774 expr->BuildConstantElements(isolate()); | 1724 expr->BuildConstantElements(isolate()); |
1775 int flags = expr->depth() == 1 | 1725 int flags = expr->depth() == 1 ? ArrayLiteral::kShallowElements |
1776 ? ArrayLiteral::kShallowElements | 1726 : ArrayLiteral::kNoFlags; |
1777 : ArrayLiteral::kNoFlags; | |
1778 | 1727 |
1779 ZoneList<Expression*>* subexprs = expr->values(); | 1728 ZoneList<Expression*>* subexprs = expr->values(); |
1780 int length = subexprs->length(); | 1729 int length = subexprs->length(); |
1781 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1730 Handle<FixedArray> constant_elements = expr->constant_elements(); |
1782 DCHECK_EQ(2, constant_elements->length()); | 1731 DCHECK_EQ(2, constant_elements->length()); |
1783 ElementsKind constant_elements_kind = | 1732 ElementsKind constant_elements_kind = |
1784 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 1733 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
1785 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); | 1734 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); |
1786 Handle<FixedArrayBase> constant_elements_values( | 1735 Handle<FixedArrayBase> constant_elements_values( |
1787 FixedArrayBase::cast(constant_elements->get(1))); | 1736 FixedArrayBase::cast(constant_elements->get(1))); |
1788 | 1737 |
1789 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; | 1738 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; |
1790 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { | 1739 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { |
1791 // If the only customer of allocation sites is transitioning, then | 1740 // If the only customer of allocation sites is transitioning, then |
1792 // we can turn it off if we don't have anywhere else to transition to. | 1741 // we can turn it off if we don't have anywhere else to transition to. |
1793 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1742 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
1794 } | 1743 } |
1795 | 1744 |
1796 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1745 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1797 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); | 1746 __ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset)); |
1798 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); | 1747 __ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index())); |
1799 __ mov(r1, Operand(constant_elements)); | 1748 __ mov(r4, Operand(constant_elements)); |
1800 if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { | 1749 if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { |
1801 __ mov(r0, Operand(Smi::FromInt(flags))); | 1750 __ LoadSmiLiteral(r3, Smi::FromInt(flags)); |
1802 __ Push(r3, r2, r1, r0); | 1751 __ Push(r6, r5, r4, r3); |
1803 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); | 1752 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); |
1804 } else { | 1753 } else { |
1805 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); | 1754 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
1806 __ CallStub(&stub); | 1755 __ CallStub(&stub); |
1807 } | 1756 } |
1808 | 1757 |
1809 bool result_saved = false; // Is the result saved to the stack? | 1758 bool result_saved = false; // Is the result saved to the stack? |
1810 | 1759 |
1811 // Emit code to evaluate all the non-constant subexpressions and to store | 1760 // Emit code to evaluate all the non-constant subexpressions and to store |
1812 // them into the newly cloned array. | 1761 // them into the newly cloned array. |
1813 for (int i = 0; i < length; i++) { | 1762 for (int i = 0; i < length; i++) { |
1814 Expression* subexpr = subexprs->at(i); | 1763 Expression* subexpr = subexprs->at(i); |
1815 // If the subexpression is a literal or a simple materialized literal it | 1764 // If the subexpression is a literal or a simple materialized literal it |
1816 // is already set in the cloned array. | 1765 // is already set in the cloned array. |
1817 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1766 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
1818 | 1767 |
1819 if (!result_saved) { | 1768 if (!result_saved) { |
1820 __ push(r0); | 1769 __ push(r3); |
1821 __ Push(Smi::FromInt(expr->literal_index())); | 1770 __ Push(Smi::FromInt(expr->literal_index())); |
1822 result_saved = true; | 1771 result_saved = true; |
1823 } | 1772 } |
1824 VisitForAccumulatorValue(subexpr); | 1773 VisitForAccumulatorValue(subexpr); |
1825 | 1774 |
1826 if (IsFastObjectElementsKind(constant_elements_kind)) { | 1775 if (IsFastObjectElementsKind(constant_elements_kind)) { |
1827 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1776 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
1828 __ ldr(r6, MemOperand(sp, kPointerSize)); // Copy of array literal. | 1777 __ LoadP(r8, MemOperand(sp, kPointerSize)); // Copy of array literal. |
1829 __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset)); | 1778 __ LoadP(r4, FieldMemOperand(r8, JSObject::kElementsOffset)); |
1830 __ str(result_register(), FieldMemOperand(r1, offset)); | 1779 __ StoreP(result_register(), FieldMemOperand(r4, offset), r0); |
1831 // Update the write barrier for the array store. | 1780 // Update the write barrier for the array store. |
1832 __ RecordWriteField(r1, offset, result_register(), r2, | 1781 __ RecordWriteField(r4, offset, result_register(), r5, kLRHasBeenSaved, |
1833 kLRHasBeenSaved, kDontSaveFPRegs, | 1782 kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
1834 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); | 1783 INLINE_SMI_CHECK); |
1835 } else { | 1784 } else { |
1836 __ mov(r3, Operand(Smi::FromInt(i))); | 1785 __ LoadSmiLiteral(r6, Smi::FromInt(i)); |
1837 StoreArrayLiteralElementStub stub(isolate()); | 1786 StoreArrayLiteralElementStub stub(isolate()); |
1838 __ CallStub(&stub); | 1787 __ CallStub(&stub); |
1839 } | 1788 } |
1840 | 1789 |
1841 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); | 1790 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); |
1842 } | 1791 } |
1843 | 1792 |
1844 if (result_saved) { | 1793 if (result_saved) { |
1845 __ pop(); // literal index | 1794 __ pop(); // literal index |
1846 context()->PlugTOS(); | 1795 context()->PlugTOS(); |
1847 } else { | 1796 } else { |
1848 context()->Plug(r0); | 1797 context()->Plug(r3); |
1849 } | 1798 } |
1850 } | 1799 } |
1851 | 1800 |
1852 | 1801 |
1853 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1802 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
1854 DCHECK(expr->target()->IsValidReferenceExpression()); | 1803 DCHECK(expr->target()->IsValidReferenceExpression()); |
1855 | 1804 |
1856 Comment cmnt(masm_, "[ Assignment"); | 1805 Comment cmnt(masm_, "[ Assignment"); |
1857 | 1806 |
1858 // Left-hand side can only be a property, a global or a (parameter or local) | 1807 // Left-hand side can only be a property, a global or a (parameter or local) |
1859 // slot. | 1808 // slot. |
1860 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | 1809 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
1861 LhsKind assign_type = VARIABLE; | 1810 LhsKind assign_type = VARIABLE; |
1862 Property* property = expr->target()->AsProperty(); | 1811 Property* property = expr->target()->AsProperty(); |
1863 if (property != NULL) { | 1812 if (property != NULL) { |
1864 assign_type = (property->key()->IsPropertyName()) | 1813 assign_type = |
1865 ? NAMED_PROPERTY | 1814 (property->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; |
1866 : KEYED_PROPERTY; | |
1867 } | 1815 } |
1868 | 1816 |
1869 // Evaluate LHS expression. | 1817 // Evaluate LHS expression. |
1870 switch (assign_type) { | 1818 switch (assign_type) { |
1871 case VARIABLE: | 1819 case VARIABLE: |
1872 // Nothing to do here. | 1820 // Nothing to do here. |
1873 break; | 1821 break; |
1874 case NAMED_PROPERTY: | 1822 case NAMED_PROPERTY: |
1875 if (expr->is_compound()) { | 1823 if (expr->is_compound()) { |
1876 // We need the receiver both on the stack and in the register. | 1824 // We need the receiver both on the stack and in the register. |
1877 VisitForStackValue(property->obj()); | 1825 VisitForStackValue(property->obj()); |
1878 __ ldr(LoadIC::ReceiverRegister(), MemOperand(sp, 0)); | 1826 __ LoadP(LoadIC::ReceiverRegister(), MemOperand(sp, 0)); |
1879 } else { | 1827 } else { |
1880 VisitForStackValue(property->obj()); | 1828 VisitForStackValue(property->obj()); |
1881 } | 1829 } |
1882 break; | 1830 break; |
1883 case KEYED_PROPERTY: | 1831 case KEYED_PROPERTY: |
1884 if (expr->is_compound()) { | 1832 if (expr->is_compound()) { |
1885 VisitForStackValue(property->obj()); | 1833 VisitForStackValue(property->obj()); |
1886 VisitForStackValue(property->key()); | 1834 VisitForStackValue(property->key()); |
1887 __ ldr(LoadIC::ReceiverRegister(), MemOperand(sp, 1 * kPointerSize)); | 1835 __ LoadP(LoadIC::ReceiverRegister(), MemOperand(sp, 1 * kPointerSize)); |
1888 __ ldr(LoadIC::NameRegister(), MemOperand(sp, 0)); | 1836 __ LoadP(LoadIC::NameRegister(), MemOperand(sp, 0)); |
1889 } else { | 1837 } else { |
1890 VisitForStackValue(property->obj()); | 1838 VisitForStackValue(property->obj()); |
1891 VisitForStackValue(property->key()); | 1839 VisitForStackValue(property->key()); |
1892 } | 1840 } |
1893 break; | 1841 break; |
1894 } | 1842 } |
1895 | 1843 |
1896 // For compound assignments we need another deoptimization point after the | 1844 // For compound assignments we need another deoptimization point after the |
1897 // variable/property load. | 1845 // variable/property load. |
1898 if (expr->is_compound()) { | 1846 if (expr->is_compound()) { |
1899 { AccumulatorValueContext context(this); | 1847 { |
| 1848 AccumulatorValueContext context(this); |
1900 switch (assign_type) { | 1849 switch (assign_type) { |
1901 case VARIABLE: | 1850 case VARIABLE: |
1902 EmitVariableLoad(expr->target()->AsVariableProxy()); | 1851 EmitVariableLoad(expr->target()->AsVariableProxy()); |
1903 PrepareForBailout(expr->target(), TOS_REG); | 1852 PrepareForBailout(expr->target(), TOS_REG); |
1904 break; | 1853 break; |
1905 case NAMED_PROPERTY: | 1854 case NAMED_PROPERTY: |
1906 EmitNamedPropertyLoad(property); | 1855 EmitNamedPropertyLoad(property); |
1907 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1856 PrepareForBailoutForId(property->LoadId(), TOS_REG); |
1908 break; | 1857 break; |
1909 case KEYED_PROPERTY: | 1858 case KEYED_PROPERTY: |
1910 EmitKeyedPropertyLoad(property); | 1859 EmitKeyedPropertyLoad(property); |
1911 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1860 PrepareForBailoutForId(property->LoadId(), TOS_REG); |
1912 break; | 1861 break; |
1913 } | 1862 } |
1914 } | 1863 } |
1915 | 1864 |
1916 Token::Value op = expr->binary_op(); | 1865 Token::Value op = expr->binary_op(); |
1917 __ push(r0); // Left operand goes on the stack. | 1866 __ push(r3); // Left operand goes on the stack. |
1918 VisitForAccumulatorValue(expr->value()); | 1867 VisitForAccumulatorValue(expr->value()); |
1919 | 1868 |
1920 OverwriteMode mode = expr->value()->ResultOverwriteAllowed() | 1869 OverwriteMode mode = expr->value()->ResultOverwriteAllowed() |
1921 ? OVERWRITE_RIGHT | 1870 ? OVERWRITE_RIGHT |
1922 : NO_OVERWRITE; | 1871 : NO_OVERWRITE; |
1923 SetSourcePosition(expr->position() + 1); | 1872 SetSourcePosition(expr->position() + 1); |
1924 AccumulatorValueContext context(this); | 1873 AccumulatorValueContext context(this); |
1925 if (ShouldInlineSmiCase(op)) { | 1874 if (ShouldInlineSmiCase(op)) { |
1926 EmitInlineSmiBinaryOp(expr->binary_operation(), | 1875 EmitInlineSmiBinaryOp(expr->binary_operation(), op, mode, expr->target(), |
1927 op, | |
1928 mode, | |
1929 expr->target(), | |
1930 expr->value()); | 1876 expr->value()); |
1931 } else { | 1877 } else { |
1932 EmitBinaryOp(expr->binary_operation(), op, mode); | 1878 EmitBinaryOp(expr->binary_operation(), op, mode); |
1933 } | 1879 } |
1934 | 1880 |
1935 // Deoptimization point in case the binary operation may have side effects. | 1881 // Deoptimization point in case the binary operation may have side effects. |
1936 PrepareForBailout(expr->binary_operation(), TOS_REG); | 1882 PrepareForBailout(expr->binary_operation(), TOS_REG); |
1937 } else { | 1883 } else { |
1938 VisitForAccumulatorValue(expr->value()); | 1884 VisitForAccumulatorValue(expr->value()); |
1939 } | 1885 } |
1940 | 1886 |
1941 // Record source position before possible IC call. | 1887 // Record source position before possible IC call. |
1942 SetSourcePosition(expr->position()); | 1888 SetSourcePosition(expr->position()); |
1943 | 1889 |
1944 // Store the value. | 1890 // Store the value. |
1945 switch (assign_type) { | 1891 switch (assign_type) { |
1946 case VARIABLE: | 1892 case VARIABLE: |
1947 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), | 1893 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), |
1948 expr->op()); | 1894 expr->op()); |
1949 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 1895 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
1950 context()->Plug(r0); | 1896 context()->Plug(r3); |
1951 break; | 1897 break; |
1952 case NAMED_PROPERTY: | 1898 case NAMED_PROPERTY: |
1953 EmitNamedPropertyAssignment(expr); | 1899 EmitNamedPropertyAssignment(expr); |
1954 break; | 1900 break; |
1955 case KEYED_PROPERTY: | 1901 case KEYED_PROPERTY: |
1956 EmitKeyedPropertyAssignment(expr); | 1902 EmitKeyedPropertyAssignment(expr); |
1957 break; | 1903 break; |
1958 } | 1904 } |
1959 } | 1905 } |
1960 | 1906 |
1961 | 1907 |
1962 void FullCodeGenerator::VisitYield(Yield* expr) { | 1908 void FullCodeGenerator::VisitYield(Yield* expr) { |
1963 Comment cmnt(masm_, "[ Yield"); | 1909 Comment cmnt(masm_, "[ Yield"); |
1964 // Evaluate yielded value first; the initial iterator definition depends on | 1910 // Evaluate yielded value first; the initial iterator definition depends on |
1965 // this. It stays on the stack while we update the iterator. | 1911 // this. It stays on the stack while we update the iterator. |
1966 VisitForStackValue(expr->expression()); | 1912 VisitForStackValue(expr->expression()); |
1967 | 1913 |
1968 switch (expr->yield_kind()) { | 1914 switch (expr->yield_kind()) { |
1969 case Yield::SUSPEND: | 1915 case Yield::SUSPEND: |
1970 // Pop value from top-of-stack slot; box result into result register. | 1916 // Pop value from top-of-stack slot; box result into result register. |
1971 EmitCreateIteratorResult(false); | 1917 EmitCreateIteratorResult(false); |
1972 __ push(result_register()); | 1918 __ push(result_register()); |
1973 // Fall through. | 1919 // Fall through. |
1974 case Yield::INITIAL: { | 1920 case Yield::INITIAL: { |
1975 Label suspend, continuation, post_runtime, resume; | 1921 Label suspend, continuation, post_runtime, resume; |
1976 | 1922 |
1977 __ jmp(&suspend); | 1923 __ b(&suspend); |
1978 | 1924 |
1979 __ bind(&continuation); | 1925 __ bind(&continuation); |
1980 __ jmp(&resume); | 1926 __ b(&resume); |
1981 | 1927 |
1982 __ bind(&suspend); | 1928 __ bind(&suspend); |
1983 VisitForAccumulatorValue(expr->generator_object()); | 1929 VisitForAccumulatorValue(expr->generator_object()); |
1984 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 1930 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
1985 __ mov(r1, Operand(Smi::FromInt(continuation.pos()))); | 1931 __ LoadSmiLiteral(r4, Smi::FromInt(continuation.pos())); |
1986 __ str(r1, FieldMemOperand(r0, JSGeneratorObject::kContinuationOffset)); | 1932 __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset), |
1987 __ str(cp, FieldMemOperand(r0, JSGeneratorObject::kContextOffset)); | 1933 r0); |
1988 __ mov(r1, cp); | 1934 __ StoreP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset), r0); |
1989 __ RecordWriteField(r0, JSGeneratorObject::kContextOffset, r1, r2, | 1935 __ mr(r4, cp); |
| 1936 __ RecordWriteField(r3, JSGeneratorObject::kContextOffset, r4, r5, |
1990 kLRHasBeenSaved, kDontSaveFPRegs); | 1937 kLRHasBeenSaved, kDontSaveFPRegs); |
1991 __ add(r1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); | 1938 __ addi(r4, fp, Operand(StandardFrameConstants::kExpressionsOffset)); |
1992 __ cmp(sp, r1); | 1939 __ cmp(sp, r4); |
1993 __ b(eq, &post_runtime); | 1940 __ beq(&post_runtime); |
1994 __ push(r0); // generator object | 1941 __ push(r3); // generator object |
1995 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1942 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
1996 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1943 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
1997 __ bind(&post_runtime); | 1944 __ bind(&post_runtime); |
1998 __ pop(result_register()); | 1945 __ pop(result_register()); |
1999 EmitReturnSequence(); | 1946 EmitReturnSequence(); |
2000 | 1947 |
2001 __ bind(&resume); | 1948 __ bind(&resume); |
2002 context()->Plug(result_register()); | 1949 context()->Plug(result_register()); |
2003 break; | 1950 break; |
2004 } | 1951 } |
2005 | 1952 |
2006 case Yield::FINAL: { | 1953 case Yield::FINAL: { |
2007 VisitForAccumulatorValue(expr->generator_object()); | 1954 VisitForAccumulatorValue(expr->generator_object()); |
2008 __ mov(r1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); | 1955 __ LoadSmiLiteral(r4, Smi::FromInt(JSGeneratorObject::kGeneratorClosed)); |
2009 __ str(r1, FieldMemOperand(result_register(), | 1956 __ StoreP(r4, FieldMemOperand(result_register(), |
2010 JSGeneratorObject::kContinuationOffset)); | 1957 JSGeneratorObject::kContinuationOffset), |
| 1958 r0); |
2011 // Pop value from top-of-stack slot, box result into result register. | 1959 // Pop value from top-of-stack slot, box result into result register. |
2012 EmitCreateIteratorResult(true); | 1960 EmitCreateIteratorResult(true); |
2013 EmitUnwindBeforeReturn(); | 1961 EmitUnwindBeforeReturn(); |
2014 EmitReturnSequence(); | 1962 EmitReturnSequence(); |
2015 break; | 1963 break; |
2016 } | 1964 } |
2017 | 1965 |
2018 case Yield::DELEGATING: { | 1966 case Yield::DELEGATING: { |
2019 VisitForStackValue(expr->generator_object()); | 1967 VisitForStackValue(expr->generator_object()); |
2020 | 1968 |
2021 // Initial stack layout is as follows: | 1969 // Initial stack layout is as follows: |
2022 // [sp + 1 * kPointerSize] iter | 1970 // [sp + 1 * kPointerSize] iter |
2023 // [sp + 0 * kPointerSize] g | 1971 // [sp + 0 * kPointerSize] g |
2024 | 1972 |
2025 Label l_catch, l_try, l_suspend, l_continuation, l_resume; | 1973 Label l_catch, l_try, l_suspend, l_continuation, l_resume; |
2026 Label l_next, l_call, l_loop; | 1974 Label l_next, l_call; |
2027 Register load_receiver = LoadIC::ReceiverRegister(); | 1975 Register load_receiver = LoadIC::ReceiverRegister(); |
2028 Register load_name = LoadIC::NameRegister(); | 1976 Register load_name = LoadIC::NameRegister(); |
2029 | 1977 |
2030 // Initial send value is undefined. | 1978 // Initial send value is undefined. |
2031 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 1979 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
2032 __ b(&l_next); | 1980 __ b(&l_next); |
2033 | 1981 |
2034 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | 1982 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } |
2035 __ bind(&l_catch); | 1983 __ bind(&l_catch); |
2036 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); | 1984 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); |
2037 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw" | 1985 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw" |
2038 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter | 1986 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter |
2039 __ Push(load_name, r3, r0); // "throw", iter, except | 1987 __ Push(load_name, r6, r3); // "throw", iter, except |
2040 __ jmp(&l_call); | 1988 __ b(&l_call); |
2041 | 1989 |
2042 // try { received = %yield result } | 1990 // try { received = %yield result } |
2043 // Shuffle the received result above a try handler and yield it without | 1991 // Shuffle the received result above a try handler and yield it without |
2044 // re-boxing. | 1992 // re-boxing. |
2045 __ bind(&l_try); | 1993 __ bind(&l_try); |
2046 __ pop(r0); // result | 1994 __ pop(r3); // result |
2047 __ PushTryHandler(StackHandler::CATCH, expr->index()); | 1995 __ PushTryHandler(StackHandler::CATCH, expr->index()); |
2048 const int handler_size = StackHandlerConstants::kSize; | 1996 const int handler_size = StackHandlerConstants::kSize; |
2049 __ push(r0); // result | 1997 __ push(r3); // result |
2050 __ jmp(&l_suspend); | 1998 __ b(&l_suspend); |
2051 __ bind(&l_continuation); | 1999 __ bind(&l_continuation); |
2052 __ jmp(&l_resume); | 2000 __ b(&l_resume); |
2053 __ bind(&l_suspend); | 2001 __ bind(&l_suspend); |
2054 const int generator_object_depth = kPointerSize + handler_size; | 2002 const int generator_object_depth = kPointerSize + handler_size; |
2055 __ ldr(r0, MemOperand(sp, generator_object_depth)); | 2003 __ LoadP(r3, MemOperand(sp, generator_object_depth)); |
2056 __ push(r0); // g | 2004 __ push(r3); // g |
2057 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | 2005 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
2058 __ mov(r1, Operand(Smi::FromInt(l_continuation.pos()))); | 2006 __ LoadSmiLiteral(r4, Smi::FromInt(l_continuation.pos())); |
2059 __ str(r1, FieldMemOperand(r0, JSGeneratorObject::kContinuationOffset)); | 2007 __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset), |
2060 __ str(cp, FieldMemOperand(r0, JSGeneratorObject::kContextOffset)); | 2008 r0); |
2061 __ mov(r1, cp); | 2009 __ StoreP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset), r0); |
2062 __ RecordWriteField(r0, JSGeneratorObject::kContextOffset, r1, r2, | 2010 __ mr(r4, cp); |
| 2011 __ RecordWriteField(r3, JSGeneratorObject::kContextOffset, r4, r5, |
2063 kLRHasBeenSaved, kDontSaveFPRegs); | 2012 kLRHasBeenSaved, kDontSaveFPRegs); |
2064 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 2013 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
2065 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2014 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2066 __ pop(r0); // result | 2015 __ pop(r3); // result |
2067 EmitReturnSequence(); | 2016 EmitReturnSequence(); |
2068 __ bind(&l_resume); // received in r0 | 2017 __ bind(&l_resume); // received in r3 |
2069 __ PopTryHandler(); | 2018 __ PopTryHandler(); |
2070 | 2019 |
2071 // receiver = iter; f = 'next'; arg = received; | 2020 // receiver = iter; f = 'next'; arg = received; |
2072 __ bind(&l_next); | 2021 __ bind(&l_next); |
2073 | 2022 |
2074 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" | 2023 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" |
2075 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter | 2024 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter |
2076 __ Push(load_name, r3, r0); // "next", iter, received | 2025 __ Push(load_name, r6, r3); // "next", iter, received |
2077 | 2026 |
2078 // result = receiver[f](arg); | 2027 // result = receiver[f](arg); |
2079 __ bind(&l_call); | 2028 __ bind(&l_call); |
2080 __ ldr(load_receiver, MemOperand(sp, kPointerSize)); | 2029 __ LoadP(load_receiver, MemOperand(sp, kPointerSize)); |
2081 __ ldr(load_name, MemOperand(sp, 2 * kPointerSize)); | 2030 __ LoadP(load_name, MemOperand(sp, 2 * kPointerSize)); |
2082 if (FLAG_vector_ics) { | 2031 if (FLAG_vector_ics) { |
2083 __ mov(LoadIC::SlotRegister(), | 2032 __ mov(LoadIC::SlotRegister(), |
2084 Operand(Smi::FromInt(expr->KeyedLoadFeedbackSlot()))); | 2033 Operand(Smi::FromInt(expr->KeyedLoadFeedbackSlot()))); |
2085 } | 2034 } |
2086 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2035 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
2087 CallIC(ic, TypeFeedbackId::None()); | 2036 CallIC(ic, TypeFeedbackId::None()); |
2088 __ mov(r1, r0); | 2037 __ mr(r4, r3); |
2089 __ str(r1, MemOperand(sp, 2 * kPointerSize)); | 2038 __ StoreP(r4, MemOperand(sp, 2 * kPointerSize)); |
2090 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2039 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2091 __ CallStub(&stub); | 2040 __ CallStub(&stub); |
2092 | 2041 |
2093 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2042 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2094 __ Drop(1); // The function is still on the stack; drop it. | 2043 __ Drop(1); // The function is still on the stack; drop it. |
2095 | 2044 |
2096 // if (!result.done) goto l_try; | 2045 // if (!result.done) goto l_try; |
2097 __ bind(&l_loop); | 2046 __ Move(load_receiver, r3); |
2098 __ Move(load_receiver, r0); | |
2099 | 2047 |
2100 __ push(load_receiver); // save result | 2048 __ push(load_receiver); // save result |
2101 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | 2049 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" |
2102 if (FLAG_vector_ics) { | 2050 if (FLAG_vector_ics) { |
2103 __ mov(LoadIC::SlotRegister(), | 2051 __ mov(LoadIC::SlotRegister(), |
2104 Operand(Smi::FromInt(expr->DoneFeedbackSlot()))); | 2052 Operand(Smi::FromInt(expr->DoneFeedbackSlot()))); |
2105 } | 2053 } |
2106 CallLoadIC(NOT_CONTEXTUAL); // r0=result.done | 2054 CallLoadIC(NOT_CONTEXTUAL); // r0=result.done |
2107 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2055 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
2108 CallIC(bool_ic); | 2056 CallIC(bool_ic); |
2109 __ cmp(r0, Operand(0)); | 2057 __ cmpi(r3, Operand::Zero()); |
2110 __ b(eq, &l_try); | 2058 __ beq(&l_try); |
2111 | 2059 |
2112 // result.value | 2060 // result.value |
2113 __ pop(load_receiver); // result | 2061 __ pop(load_receiver); // result |
2114 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" | 2062 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" |
2115 if (FLAG_vector_ics) { | 2063 if (FLAG_vector_ics) { |
2116 __ mov(LoadIC::SlotRegister(), | 2064 __ mov(LoadIC::SlotRegister(), |
2117 Operand(Smi::FromInt(expr->ValueFeedbackSlot()))); | 2065 Operand(Smi::FromInt(expr->ValueFeedbackSlot()))); |
2118 } | 2066 } |
2119 CallLoadIC(NOT_CONTEXTUAL); // r0=result.value | 2067 CallLoadIC(NOT_CONTEXTUAL); // r3=result.value |
2120 context()->DropAndPlug(2, r0); // drop iter and g | 2068 context()->DropAndPlug(2, r3); // drop iter and g |
2121 break; | 2069 break; |
2122 } | 2070 } |
2123 } | 2071 } |
2124 } | 2072 } |
2125 | 2073 |
2126 | 2074 |
2127 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2075 void FullCodeGenerator::EmitGeneratorResume( |
2128 Expression *value, | 2076 Expression* generator, Expression* value, |
2129 JSGeneratorObject::ResumeMode resume_mode) { | 2077 JSGeneratorObject::ResumeMode resume_mode) { |
2130 // The value stays in r0, and is ultimately read by the resumed generator, as | 2078 // The value stays in r3, and is ultimately read by the resumed generator, as |
2131 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it | 2079 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it |
2132 // is read to throw the value when the resumed generator is already closed. | 2080 // is read to throw the value when the resumed generator is already closed. |
2133 // r1 will hold the generator object until the activation has been resumed. | 2081 // r4 will hold the generator object until the activation has been resumed. |
2134 VisitForStackValue(generator); | 2082 VisitForStackValue(generator); |
2135 VisitForAccumulatorValue(value); | 2083 VisitForAccumulatorValue(value); |
2136 __ pop(r1); | 2084 __ pop(r4); |
2137 | 2085 |
2138 // Check generator state. | 2086 // Check generator state. |
2139 Label wrong_state, closed_state, done; | 2087 Label wrong_state, closed_state, done; |
2140 __ ldr(r3, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); | 2088 __ LoadP(r6, FieldMemOperand(r4, JSGeneratorObject::kContinuationOffset)); |
2141 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0); | 2089 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0); |
2142 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0); | 2090 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0); |
2143 __ cmp(r3, Operand(Smi::FromInt(0))); | 2091 __ CmpSmiLiteral(r6, Smi::FromInt(0), r0); |
2144 __ b(eq, &closed_state); | 2092 __ beq(&closed_state); |
2145 __ b(lt, &wrong_state); | 2093 __ blt(&wrong_state); |
2146 | 2094 |
2147 // Load suspended function and context. | 2095 // Load suspended function and context. |
2148 __ ldr(cp, FieldMemOperand(r1, JSGeneratorObject::kContextOffset)); | 2096 __ LoadP(cp, FieldMemOperand(r4, JSGeneratorObject::kContextOffset)); |
2149 __ ldr(r4, FieldMemOperand(r1, JSGeneratorObject::kFunctionOffset)); | 2097 __ LoadP(r7, FieldMemOperand(r4, JSGeneratorObject::kFunctionOffset)); |
2150 | 2098 |
2151 // Load receiver and store as the first argument. | 2099 // Load receiver and store as the first argument. |
2152 __ ldr(r2, FieldMemOperand(r1, JSGeneratorObject::kReceiverOffset)); | 2100 __ LoadP(r5, FieldMemOperand(r4, JSGeneratorObject::kReceiverOffset)); |
2153 __ push(r2); | 2101 __ push(r5); |
2154 | 2102 |
2155 // Push holes for the rest of the arguments to the generator function. | 2103 // Push holes for the rest of the arguments to the generator function. |
2156 __ ldr(r3, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | 2104 __ LoadP(r6, FieldMemOperand(r7, JSFunction::kSharedFunctionInfoOffset)); |
2157 __ ldr(r3, | 2105 __ LoadWordArith( |
2158 FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset)); | 2106 r6, FieldMemOperand(r6, SharedFunctionInfo::kFormalParameterCountOffset)); |
2159 __ LoadRoot(r2, Heap::kTheHoleValueRootIndex); | 2107 __ LoadRoot(r5, Heap::kTheHoleValueRootIndex); |
2160 Label push_argument_holes, push_frame; | 2108 Label argument_loop, push_frame; |
2161 __ bind(&push_argument_holes); | 2109 #if V8_TARGET_ARCH_PPC64 |
2162 __ sub(r3, r3, Operand(Smi::FromInt(1)), SetCC); | 2110 __ cmpi(r6, Operand::Zero()); |
2163 __ b(mi, &push_frame); | 2111 __ beq(&push_frame); |
2164 __ push(r2); | 2112 #else |
2165 __ jmp(&push_argument_holes); | 2113 __ SmiUntag(r6, SetRC); |
| 2114 __ beq(&push_frame, cr0); |
| 2115 #endif |
| 2116 __ mtctr(r6); |
| 2117 __ bind(&argument_loop); |
| 2118 __ push(r5); |
| 2119 __ bdnz(&argument_loop); |
2166 | 2120 |
2167 // Enter a new JavaScript frame, and initialize its slots as they were when | 2121 // Enter a new JavaScript frame, and initialize its slots as they were when |
2168 // the generator was suspended. | 2122 // the generator was suspended. |
2169 Label resume_frame; | 2123 Label resume_frame; |
2170 __ bind(&push_frame); | 2124 __ bind(&push_frame); |
2171 __ bl(&resume_frame); | 2125 __ b(&resume_frame, SetLK); |
2172 __ jmp(&done); | 2126 __ b(&done); |
2173 __ bind(&resume_frame); | 2127 __ bind(&resume_frame); |
2174 // lr = return address. | 2128 // lr = return address. |
2175 // fp = caller's frame pointer. | 2129 // fp = caller's frame pointer. |
2176 // pp = caller's constant pool (if FLAG_enable_ool_constant_pool), | |
2177 // cp = callee's context, | 2130 // cp = callee's context, |
2178 // r4 = callee's JS function. | 2131 // r7 = callee's JS function. |
2179 __ PushFixedFrame(r4); | 2132 __ PushFixedFrame(r7); |
2180 // Adjust FP to point to saved FP. | 2133 // Adjust FP to point to saved FP. |
2181 __ add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); | 2134 __ addi(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); |
2182 | 2135 |
2183 // Load the operand stack size. | 2136 // Load the operand stack size. |
2184 __ ldr(r3, FieldMemOperand(r1, JSGeneratorObject::kOperandStackOffset)); | 2137 __ LoadP(r6, FieldMemOperand(r4, JSGeneratorObject::kOperandStackOffset)); |
2185 __ ldr(r3, FieldMemOperand(r3, FixedArray::kLengthOffset)); | 2138 __ LoadP(r6, FieldMemOperand(r6, FixedArray::kLengthOffset)); |
2186 __ SmiUntag(r3); | 2139 __ SmiUntag(r6, SetRC); |
2187 | 2140 |
2188 // If we are sending a value and there is no operand stack, we can jump back | 2141 // If we are sending a value and there is no operand stack, we can jump back |
2189 // in directly. | 2142 // in directly. |
| 2143 Label call_resume; |
2190 if (resume_mode == JSGeneratorObject::NEXT) { | 2144 if (resume_mode == JSGeneratorObject::NEXT) { |
2191 Label slow_resume; | 2145 Label slow_resume; |
2192 __ cmp(r3, Operand(0)); | 2146 __ bne(&slow_resume, cr0); |
2193 __ b(ne, &slow_resume); | 2147 __ LoadP(r6, FieldMemOperand(r7, JSFunction::kCodeEntryOffset)); |
2194 __ ldr(r3, FieldMemOperand(r4, JSFunction::kCodeEntryOffset)); | 2148 #if V8_OOL_CONSTANT_POOL |
2195 | 2149 { |
2196 { ConstantPoolUnavailableScope constant_pool_unavailable(masm_); | 2150 ConstantPoolUnavailableScope constant_pool_unavailable(masm_); |
2197 if (FLAG_enable_ool_constant_pool) { | 2151 // Load the new code object's constant pool pointer. |
2198 // Load the new code object's constant pool pointer. | 2152 __ LoadP(kConstantPoolRegister, |
2199 __ ldr(pp, | 2153 MemOperand(r6, Code::kConstantPoolOffset - Code::kHeaderSize)); |
2200 MemOperand(r3, Code::kConstantPoolOffset - Code::kHeaderSize)); | 2154 #endif |
2201 } | 2155 __ LoadP(r5, FieldMemOperand(r4, JSGeneratorObject::kContinuationOffset)); |
2202 | 2156 __ SmiUntag(r5); |
2203 __ ldr(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); | 2157 __ add(r6, r6, r5); |
2204 __ SmiUntag(r2); | 2158 __ LoadSmiLiteral(r5, |
2205 __ add(r3, r3, r2); | 2159 Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)); |
2206 __ mov(r2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); | 2160 __ StoreP(r5, FieldMemOperand(r4, JSGeneratorObject::kContinuationOffset), |
2207 __ str(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); | 2161 r0); |
2208 __ Jump(r3); | 2162 __ Jump(r6); |
| 2163 __ bind(&slow_resume); |
| 2164 #if V8_OOL_CONSTANT_POOL |
2209 } | 2165 } |
2210 __ bind(&slow_resume); | 2166 #endif |
| 2167 } else { |
| 2168 __ beq(&call_resume, cr0); |
2211 } | 2169 } |
2212 | 2170 |
2213 // Otherwise, we push holes for the operand stack and call the runtime to fix | 2171 // Otherwise, we push holes for the operand stack and call the runtime to fix |
2214 // up the stack and the handlers. | 2172 // up the stack and the handlers. |
2215 Label push_operand_holes, call_resume; | 2173 Label operand_loop; |
2216 __ bind(&push_operand_holes); | 2174 __ mtctr(r6); |
2217 __ sub(r3, r3, Operand(1), SetCC); | 2175 __ bind(&operand_loop); |
2218 __ b(mi, &call_resume); | 2176 __ push(r5); |
2219 __ push(r2); | 2177 __ bdnz(&operand_loop); |
2220 __ b(&push_operand_holes); | 2178 |
2221 __ bind(&call_resume); | 2179 __ bind(&call_resume); |
2222 DCHECK(!result_register().is(r1)); | 2180 DCHECK(!result_register().is(r4)); |
2223 __ Push(r1, result_register()); | 2181 __ Push(r4, result_register()); |
2224 __ Push(Smi::FromInt(resume_mode)); | 2182 __ Push(Smi::FromInt(resume_mode)); |
2225 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); | 2183 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); |
2226 // Not reached: the runtime call returns elsewhere. | 2184 // Not reached: the runtime call returns elsewhere. |
2227 __ stop("not-reached"); | 2185 __ stop("not-reached"); |
2228 | 2186 |
2229 // Reach here when generator is closed. | 2187 // Reach here when generator is closed. |
2230 __ bind(&closed_state); | 2188 __ bind(&closed_state); |
2231 if (resume_mode == JSGeneratorObject::NEXT) { | 2189 if (resume_mode == JSGeneratorObject::NEXT) { |
2232 // Return completed iterator result when generator is closed. | 2190 // Return completed iterator result when generator is closed. |
2233 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 2191 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
2234 __ push(r2); | 2192 __ push(r5); |
2235 // Pop value from top-of-stack slot; box result into result register. | 2193 // Pop value from top-of-stack slot; box result into result register. |
2236 EmitCreateIteratorResult(true); | 2194 EmitCreateIteratorResult(true); |
2237 } else { | 2195 } else { |
2238 // Throw the provided value. | 2196 // Throw the provided value. |
2239 __ push(r0); | 2197 __ push(r3); |
2240 __ CallRuntime(Runtime::kThrow, 1); | 2198 __ CallRuntime(Runtime::kThrow, 1); |
2241 } | 2199 } |
2242 __ jmp(&done); | 2200 __ b(&done); |
2243 | 2201 |
2244 // Throw error if we attempt to operate on a running generator. | 2202 // Throw error if we attempt to operate on a running generator. |
2245 __ bind(&wrong_state); | 2203 __ bind(&wrong_state); |
2246 __ push(r1); | 2204 __ push(r4); |
2247 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); | 2205 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); |
2248 | 2206 |
2249 __ bind(&done); | 2207 __ bind(&done); |
2250 context()->Plug(result_register()); | 2208 context()->Plug(result_register()); |
2251 } | 2209 } |
2252 | 2210 |
2253 | 2211 |
2254 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { | 2212 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { |
2255 Label gc_required; | 2213 Label gc_required; |
2256 Label allocated; | 2214 Label allocated; |
2257 | 2215 |
2258 Handle<Map> map(isolate()->native_context()->iterator_result_map()); | 2216 Handle<Map> map(isolate()->native_context()->iterator_result_map()); |
2259 | 2217 |
2260 __ Allocate(map->instance_size(), r0, r2, r3, &gc_required, TAG_OBJECT); | 2218 __ Allocate(map->instance_size(), r3, r5, r6, &gc_required, TAG_OBJECT); |
2261 __ jmp(&allocated); | 2219 __ b(&allocated); |
2262 | 2220 |
2263 __ bind(&gc_required); | 2221 __ bind(&gc_required); |
2264 __ Push(Smi::FromInt(map->instance_size())); | 2222 __ Push(Smi::FromInt(map->instance_size())); |
2265 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 2223 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
2266 __ ldr(context_register(), | 2224 __ LoadP(context_register(), |
2267 MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2225 MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2268 | 2226 |
2269 __ bind(&allocated); | 2227 __ bind(&allocated); |
2270 __ mov(r1, Operand(map)); | 2228 __ mov(r4, Operand(map)); |
2271 __ pop(r2); | 2229 __ pop(r5); |
2272 __ mov(r3, Operand(isolate()->factory()->ToBoolean(done))); | 2230 __ mov(r6, Operand(isolate()->factory()->ToBoolean(done))); |
2273 __ mov(r4, Operand(isolate()->factory()->empty_fixed_array())); | 2231 __ mov(r7, Operand(isolate()->factory()->empty_fixed_array())); |
2274 DCHECK_EQ(map->instance_size(), 5 * kPointerSize); | 2232 DCHECK_EQ(map->instance_size(), 5 * kPointerSize); |
2275 __ str(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | 2233 __ StoreP(r4, FieldMemOperand(r3, HeapObject::kMapOffset), r0); |
2276 __ str(r4, FieldMemOperand(r0, JSObject::kPropertiesOffset)); | 2234 __ StoreP(r7, FieldMemOperand(r3, JSObject::kPropertiesOffset), r0); |
2277 __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset)); | 2235 __ StoreP(r7, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
2278 __ str(r2, | 2236 __ StoreP(r5, |
2279 FieldMemOperand(r0, JSGeneratorObject::kResultValuePropertyOffset)); | 2237 FieldMemOperand(r3, JSGeneratorObject::kResultValuePropertyOffset), |
2280 __ str(r3, | 2238 r0); |
2281 FieldMemOperand(r0, JSGeneratorObject::kResultDonePropertyOffset)); | 2239 __ StoreP(r6, |
| 2240 FieldMemOperand(r3, JSGeneratorObject::kResultDonePropertyOffset), |
| 2241 r0); |
2282 | 2242 |
2283 // Only the value field needs a write barrier, as the other values are in the | 2243 // Only the value field needs a write barrier, as the other values are in the |
2284 // root set. | 2244 // root set. |
2285 __ RecordWriteField(r0, JSGeneratorObject::kResultValuePropertyOffset, | 2245 __ RecordWriteField(r3, JSGeneratorObject::kResultValuePropertyOffset, r5, r6, |
2286 r2, r3, kLRHasBeenSaved, kDontSaveFPRegs); | 2246 kLRHasBeenSaved, kDontSaveFPRegs); |
2287 } | 2247 } |
2288 | 2248 |
2289 | 2249 |
2290 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2250 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2291 SetSourcePosition(prop->position()); | 2251 SetSourcePosition(prop->position()); |
2292 Literal* key = prop->key()->AsLiteral(); | 2252 Literal* key = prop->key()->AsLiteral(); |
2293 __ mov(LoadIC::NameRegister(), Operand(key->value())); | 2253 __ mov(LoadIC::NameRegister(), Operand(key->value())); |
2294 if (FLAG_vector_ics) { | 2254 if (FLAG_vector_ics) { |
2295 __ mov(LoadIC::SlotRegister(), | 2255 __ mov(LoadIC::SlotRegister(), |
2296 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2256 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
(...skipping 17 matching lines...) Expand all Loading... |
2314 } | 2274 } |
2315 | 2275 |
2316 | 2276 |
2317 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, | 2277 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
2318 Token::Value op, | 2278 Token::Value op, |
2319 OverwriteMode mode, | 2279 OverwriteMode mode, |
2320 Expression* left_expr, | 2280 Expression* left_expr, |
2321 Expression* right_expr) { | 2281 Expression* right_expr) { |
2322 Label done, smi_case, stub_call; | 2282 Label done, smi_case, stub_call; |
2323 | 2283 |
2324 Register scratch1 = r2; | 2284 Register scratch1 = r5; |
2325 Register scratch2 = r3; | 2285 Register scratch2 = r6; |
2326 | 2286 |
2327 // Get the arguments. | 2287 // Get the arguments. |
2328 Register left = r1; | 2288 Register left = r4; |
2329 Register right = r0; | 2289 Register right = r3; |
2330 __ pop(left); | 2290 __ pop(left); |
2331 | 2291 |
2332 // Perform combined smi check on both operands. | 2292 // Perform combined smi check on both operands. |
2333 __ orr(scratch1, left, Operand(right)); | 2293 __ orx(scratch1, left, right); |
2334 STATIC_ASSERT(kSmiTag == 0); | 2294 STATIC_ASSERT(kSmiTag == 0); |
2335 JumpPatchSite patch_site(masm_); | 2295 JumpPatchSite patch_site(masm_); |
2336 patch_site.EmitJumpIfSmi(scratch1, &smi_case); | 2296 patch_site.EmitJumpIfSmi(scratch1, &smi_case); |
2337 | 2297 |
2338 __ bind(&stub_call); | 2298 __ bind(&stub_call); |
2339 BinaryOpICStub stub(isolate(), op, mode); | 2299 BinaryOpICStub stub(isolate(), op, mode); |
2340 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); | 2300 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); |
2341 patch_site.EmitPatchInfo(); | 2301 patch_site.EmitPatchInfo(); |
2342 __ jmp(&done); | 2302 __ b(&done); |
2343 | 2303 |
2344 __ bind(&smi_case); | 2304 __ bind(&smi_case); |
2345 // Smi case. This code works the same way as the smi-smi case in the type | 2305 // Smi case. This code works the same way as the smi-smi case in the type |
2346 // recording binary operation stub, see | 2306 // recording binary operation stub. |
2347 switch (op) { | 2307 switch (op) { |
2348 case Token::SAR: | 2308 case Token::SAR: |
2349 __ GetLeastBitsFromSmi(scratch1, right, 5); | 2309 __ GetLeastBitsFromSmi(scratch1, right, 5); |
2350 __ mov(right, Operand(left, ASR, scratch1)); | 2310 __ ShiftRightArith(right, left, scratch1); |
2351 __ bic(right, right, Operand(kSmiTagMask)); | 2311 __ ClearRightImm(right, right, Operand(kSmiTagSize + kSmiShiftSize)); |
2352 break; | 2312 break; |
2353 case Token::SHL: { | 2313 case Token::SHL: { |
| 2314 __ GetLeastBitsFromSmi(scratch2, right, 5); |
| 2315 #if V8_TARGET_ARCH_PPC64 |
| 2316 __ ShiftLeft(right, left, scratch2); |
| 2317 #else |
2354 __ SmiUntag(scratch1, left); | 2318 __ SmiUntag(scratch1, left); |
2355 __ GetLeastBitsFromSmi(scratch2, right, 5); | 2319 __ ShiftLeft(scratch1, scratch1, scratch2); |
2356 __ mov(scratch1, Operand(scratch1, LSL, scratch2)); | 2320 // Check that the *signed* result fits in a smi |
2357 __ TrySmiTag(right, scratch1, &stub_call); | 2321 __ JumpIfNotSmiCandidate(scratch1, scratch2, &stub_call); |
| 2322 __ SmiTag(right, scratch1); |
| 2323 #endif |
2358 break; | 2324 break; |
2359 } | 2325 } |
2360 case Token::SHR: { | 2326 case Token::SHR: { |
2361 __ SmiUntag(scratch1, left); | 2327 __ SmiUntag(scratch1, left); |
2362 __ GetLeastBitsFromSmi(scratch2, right, 5); | 2328 __ GetLeastBitsFromSmi(scratch2, right, 5); |
2363 __ mov(scratch1, Operand(scratch1, LSR, scratch2)); | 2329 __ srw(scratch1, scratch1, scratch2); |
2364 __ tst(scratch1, Operand(0xc0000000)); | 2330 // Unsigned shift is not allowed to produce a negative number. |
2365 __ b(ne, &stub_call); | 2331 __ JumpIfNotUnsignedSmiCandidate(scratch1, r0, &stub_call); |
2366 __ SmiTag(right, scratch1); | 2332 __ SmiTag(right, scratch1); |
2367 break; | 2333 break; |
2368 } | 2334 } |
2369 case Token::ADD: | 2335 case Token::ADD: { |
2370 __ add(scratch1, left, Operand(right), SetCC); | 2336 __ AddAndCheckForOverflow(scratch1, left, right, scratch2, r0); |
2371 __ b(vs, &stub_call); | 2337 __ bne(&stub_call, cr0); |
2372 __ mov(right, scratch1); | 2338 __ mr(right, scratch1); |
2373 break; | 2339 break; |
2374 case Token::SUB: | 2340 } |
2375 __ sub(scratch1, left, Operand(right), SetCC); | 2341 case Token::SUB: { |
2376 __ b(vs, &stub_call); | 2342 __ SubAndCheckForOverflow(scratch1, left, right, scratch2, r0); |
2377 __ mov(right, scratch1); | 2343 __ bne(&stub_call, cr0); |
| 2344 __ mr(right, scratch1); |
2378 break; | 2345 break; |
| 2346 } |
2379 case Token::MUL: { | 2347 case Token::MUL: { |
| 2348 Label mul_zero; |
| 2349 #if V8_TARGET_ARCH_PPC64 |
| 2350 // Remove tag from both operands. |
2380 __ SmiUntag(ip, right); | 2351 __ SmiUntag(ip, right); |
2381 __ smull(scratch1, scratch2, left, ip); | 2352 __ SmiUntag(r0, left); |
2382 __ mov(ip, Operand(scratch1, ASR, 31)); | 2353 __ Mul(scratch1, r0, ip); |
2383 __ cmp(ip, Operand(scratch2)); | 2354 // Check for overflowing the smi range - no overflow if higher 33 bits of |
2384 __ b(ne, &stub_call); | 2355 // the result are identical. |
2385 __ cmp(scratch1, Operand::Zero()); | 2356 __ TestIfInt32(scratch1, scratch2, ip); |
2386 __ mov(right, Operand(scratch1), LeaveCC, ne); | 2357 __ bne(&stub_call); |
2387 __ b(ne, &done); | 2358 #else |
2388 __ add(scratch2, right, Operand(left), SetCC); | 2359 __ SmiUntag(ip, right); |
2389 __ mov(right, Operand(Smi::FromInt(0)), LeaveCC, pl); | 2360 __ mullw(scratch1, left, ip); |
2390 __ b(mi, &stub_call); | 2361 __ mulhw(scratch2, left, ip); |
| 2362 // Check for overflowing the smi range - no overflow if higher 33 bits of |
| 2363 // the result are identical. |
| 2364 __ TestIfInt32(scratch2, scratch1, ip); |
| 2365 __ bne(&stub_call); |
| 2366 #endif |
| 2367 // Go slow on zero result to handle -0. |
| 2368 __ cmpi(scratch1, Operand::Zero()); |
| 2369 __ beq(&mul_zero); |
| 2370 #if V8_TARGET_ARCH_PPC64 |
| 2371 __ SmiTag(right, scratch1); |
| 2372 #else |
| 2373 __ mr(right, scratch1); |
| 2374 #endif |
| 2375 __ b(&done); |
| 2376 // We need -0 if we were multiplying a negative number with 0 to get 0. |
| 2377 // We know one of them was zero. |
| 2378 __ bind(&mul_zero); |
| 2379 __ add(scratch2, right, left); |
| 2380 __ cmpi(scratch2, Operand::Zero()); |
| 2381 __ blt(&stub_call); |
| 2382 __ LoadSmiLiteral(right, Smi::FromInt(0)); |
2391 break; | 2383 break; |
2392 } | 2384 } |
2393 case Token::BIT_OR: | 2385 case Token::BIT_OR: |
2394 __ orr(right, left, Operand(right)); | 2386 __ orx(right, left, right); |
2395 break; | 2387 break; |
2396 case Token::BIT_AND: | 2388 case Token::BIT_AND: |
2397 __ and_(right, left, Operand(right)); | 2389 __ and_(right, left, right); |
2398 break; | 2390 break; |
2399 case Token::BIT_XOR: | 2391 case Token::BIT_XOR: |
2400 __ eor(right, left, Operand(right)); | 2392 __ xor_(right, left, right); |
2401 break; | 2393 break; |
2402 default: | 2394 default: |
2403 UNREACHABLE(); | 2395 UNREACHABLE(); |
2404 } | 2396 } |
2405 | 2397 |
2406 __ bind(&done); | 2398 __ bind(&done); |
2407 context()->Plug(r0); | 2399 context()->Plug(r3); |
2408 } | 2400 } |
2409 | 2401 |
2410 | 2402 |
2411 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 2403 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op, |
2412 Token::Value op, | |
2413 OverwriteMode mode) { | 2404 OverwriteMode mode) { |
2414 __ pop(r1); | 2405 __ pop(r4); |
2415 BinaryOpICStub stub(isolate(), op, mode); | 2406 BinaryOpICStub stub(isolate(), op, mode); |
2416 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2407 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2417 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); | 2408 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); |
2418 patch_site.EmitPatchInfo(); | 2409 patch_site.EmitPatchInfo(); |
2419 context()->Plug(r0); | 2410 context()->Plug(r3); |
2420 } | 2411 } |
2421 | 2412 |
2422 | 2413 |
2423 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2414 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
2424 DCHECK(expr->IsValidReferenceExpression()); | 2415 DCHECK(expr->IsValidReferenceExpression()); |
2425 | 2416 |
2426 // Left-hand side can only be a property, a global or a (parameter or local) | 2417 // Left-hand side can only be a property, a global or a (parameter or local) |
2427 // slot. | 2418 // slot. |
2428 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | 2419 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
2429 LhsKind assign_type = VARIABLE; | 2420 LhsKind assign_type = VARIABLE; |
2430 Property* prop = expr->AsProperty(); | 2421 Property* prop = expr->AsProperty(); |
2431 if (prop != NULL) { | 2422 if (prop != NULL) { |
2432 assign_type = (prop->key()->IsPropertyName()) | 2423 assign_type = |
2433 ? NAMED_PROPERTY | 2424 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; |
2434 : KEYED_PROPERTY; | |
2435 } | 2425 } |
2436 | 2426 |
2437 switch (assign_type) { | 2427 switch (assign_type) { |
2438 case VARIABLE: { | 2428 case VARIABLE: { |
2439 Variable* var = expr->AsVariableProxy()->var(); | 2429 Variable* var = expr->AsVariableProxy()->var(); |
2440 EffectContext context(this); | 2430 EffectContext context(this); |
2441 EmitVariableAssignment(var, Token::ASSIGN); | 2431 EmitVariableAssignment(var, Token::ASSIGN); |
2442 break; | 2432 break; |
2443 } | 2433 } |
2444 case NAMED_PROPERTY: { | 2434 case NAMED_PROPERTY: { |
2445 __ push(r0); // Preserve value. | 2435 __ push(r3); // Preserve value. |
2446 VisitForAccumulatorValue(prop->obj()); | 2436 VisitForAccumulatorValue(prop->obj()); |
2447 __ Move(StoreIC::ReceiverRegister(), r0); | 2437 __ Move(StoreIC::ReceiverRegister(), r3); |
2448 __ pop(StoreIC::ValueRegister()); // Restore value. | 2438 __ pop(StoreIC::ValueRegister()); // Restore value. |
2449 __ mov(StoreIC::NameRegister(), | 2439 __ mov(StoreIC::NameRegister(), |
2450 Operand(prop->key()->AsLiteral()->value())); | 2440 Operand(prop->key()->AsLiteral()->value())); |
2451 CallStoreIC(); | 2441 CallStoreIC(); |
2452 break; | 2442 break; |
2453 } | 2443 } |
2454 case KEYED_PROPERTY: { | 2444 case KEYED_PROPERTY: { |
2455 __ push(r0); // Preserve value. | 2445 __ push(r3); // Preserve value. |
2456 VisitForStackValue(prop->obj()); | 2446 VisitForStackValue(prop->obj()); |
2457 VisitForAccumulatorValue(prop->key()); | 2447 VisitForAccumulatorValue(prop->key()); |
2458 __ Move(KeyedStoreIC::NameRegister(), r0); | 2448 __ Move(KeyedStoreIC::NameRegister(), r3); |
2459 __ Pop(KeyedStoreIC::ValueRegister(), KeyedStoreIC::ReceiverRegister()); | 2449 __ Pop(KeyedStoreIC::ValueRegister(), KeyedStoreIC::ReceiverRegister()); |
2460 Handle<Code> ic = strict_mode() == SLOPPY | 2450 Handle<Code> ic = |
2461 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2451 strict_mode() == SLOPPY |
2462 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2452 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 2453 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2463 CallIC(ic); | 2454 CallIC(ic); |
2464 break; | 2455 break; |
2465 } | 2456 } |
2466 } | 2457 } |
2467 context()->Plug(r0); | 2458 context()->Plug(r3); |
2468 } | 2459 } |
2469 | 2460 |
2470 | 2461 |
2471 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( | 2462 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
2472 Variable* var, MemOperand location) { | 2463 Variable* var, MemOperand location) { |
2473 __ str(result_register(), location); | 2464 __ StoreP(result_register(), location, r0); |
2474 if (var->IsContextSlot()) { | 2465 if (var->IsContextSlot()) { |
2475 // RecordWrite may destroy all its register arguments. | 2466 // RecordWrite may destroy all its register arguments. |
2476 __ mov(r3, result_register()); | 2467 __ mr(r6, result_register()); |
2477 int offset = Context::SlotOffset(var->index()); | 2468 int offset = Context::SlotOffset(var->index()); |
2478 __ RecordWriteContextSlot( | 2469 __ RecordWriteContextSlot(r4, offset, r6, r5, kLRHasBeenSaved, |
2479 r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs); | 2470 kDontSaveFPRegs); |
2480 } | 2471 } |
2481 } | 2472 } |
2482 | 2473 |
2483 | 2474 |
2484 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op) { | 2475 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op) { |
2485 if (var->IsUnallocated()) { | 2476 if (var->IsUnallocated()) { |
2486 // Global var, const, or let. | 2477 // Global var, const, or let. |
2487 __ mov(StoreIC::NameRegister(), Operand(var->name())); | 2478 __ mov(StoreIC::NameRegister(), Operand(var->name())); |
2488 __ ldr(StoreIC::ReceiverRegister(), GlobalObjectOperand()); | 2479 __ LoadP(StoreIC::ReceiverRegister(), GlobalObjectOperand()); |
2489 CallStoreIC(); | 2480 CallStoreIC(); |
2490 | 2481 |
2491 } else if (op == Token::INIT_CONST_LEGACY) { | 2482 } else if (op == Token::INIT_CONST_LEGACY) { |
2492 // Const initializers need a write barrier. | 2483 // Const initializers need a write barrier. |
2493 DCHECK(!var->IsParameter()); // No const parameters. | 2484 DCHECK(!var->IsParameter()); // No const parameters. |
2494 if (var->IsLookupSlot()) { | 2485 if (var->IsLookupSlot()) { |
2495 __ push(r0); | 2486 __ push(r3); |
2496 __ mov(r0, Operand(var->name())); | 2487 __ mov(r3, Operand(var->name())); |
2497 __ Push(cp, r0); // Context and name. | 2488 __ Push(cp, r3); // Context and name. |
2498 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); | 2489 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); |
2499 } else { | 2490 } else { |
2500 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2491 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2501 Label skip; | 2492 Label skip; |
2502 MemOperand location = VarOperand(var, r1); | 2493 MemOperand location = VarOperand(var, r4); |
2503 __ ldr(r2, location); | 2494 __ LoadP(r5, location); |
2504 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); | 2495 __ CompareRoot(r5, Heap::kTheHoleValueRootIndex); |
2505 __ b(ne, &skip); | 2496 __ bne(&skip); |
2506 EmitStoreToStackLocalOrContextSlot(var, location); | 2497 EmitStoreToStackLocalOrContextSlot(var, location); |
2507 __ bind(&skip); | 2498 __ bind(&skip); |
2508 } | 2499 } |
2509 | 2500 |
2510 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2501 } else if (var->mode() == LET && op != Token::INIT_LET) { |
2511 // Non-initializing assignment to let variable needs a write barrier. | 2502 // Non-initializing assignment to let variable needs a write barrier. |
2512 DCHECK(!var->IsLookupSlot()); | 2503 DCHECK(!var->IsLookupSlot()); |
2513 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2504 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2514 Label assign; | 2505 Label assign; |
2515 MemOperand location = VarOperand(var, r1); | 2506 MemOperand location = VarOperand(var, r4); |
2516 __ ldr(r3, location); | 2507 __ LoadP(r6, location); |
2517 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); | 2508 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); |
2518 __ b(ne, &assign); | 2509 __ bne(&assign); |
2519 __ mov(r3, Operand(var->name())); | 2510 __ mov(r6, Operand(var->name())); |
2520 __ push(r3); | 2511 __ push(r6); |
2521 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 2512 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
2522 // Perform the assignment. | 2513 // Perform the assignment. |
2523 __ bind(&assign); | 2514 __ bind(&assign); |
2524 EmitStoreToStackLocalOrContextSlot(var, location); | 2515 EmitStoreToStackLocalOrContextSlot(var, location); |
2525 | 2516 |
2526 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { | 2517 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { |
2527 if (var->IsLookupSlot()) { | 2518 if (var->IsLookupSlot()) { |
2528 // Assignment to var. | 2519 // Assignment to var. |
2529 __ push(r0); // Value. | 2520 __ push(r3); // Value. |
2530 __ mov(r1, Operand(var->name())); | 2521 __ mov(r4, Operand(var->name())); |
2531 __ mov(r0, Operand(Smi::FromInt(strict_mode()))); | 2522 __ mov(r3, Operand(Smi::FromInt(strict_mode()))); |
2532 __ Push(cp, r1, r0); // Context, name, strict mode. | 2523 __ Push(cp, r4, r3); // Context, name, strict mode. |
2533 __ CallRuntime(Runtime::kStoreLookupSlot, 4); | 2524 __ CallRuntime(Runtime::kStoreLookupSlot, 4); |
2534 } else { | 2525 } else { |
2535 // Assignment to var or initializing assignment to let/const in harmony | 2526 // Assignment to var or initializing assignment to let/const in harmony |
2536 // mode. | 2527 // mode. |
2537 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); | 2528 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); |
2538 MemOperand location = VarOperand(var, r1); | 2529 MemOperand location = VarOperand(var, r4); |
2539 if (generate_debug_code_ && op == Token::INIT_LET) { | 2530 if (generate_debug_code_ && op == Token::INIT_LET) { |
2540 // Check for an uninitialized let binding. | 2531 // Check for an uninitialized let binding. |
2541 __ ldr(r2, location); | 2532 __ LoadP(r5, location); |
2542 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); | 2533 __ CompareRoot(r5, Heap::kTheHoleValueRootIndex); |
2543 __ Check(eq, kLetBindingReInitialization); | 2534 __ Check(eq, kLetBindingReInitialization); |
2544 } | 2535 } |
2545 EmitStoreToStackLocalOrContextSlot(var, location); | 2536 EmitStoreToStackLocalOrContextSlot(var, location); |
2546 } | 2537 } |
2547 } | 2538 } |
2548 // Non-initializing assignments to consts are ignored. | 2539 // Non-initializing assignments to consts are ignored. |
2549 } | 2540 } |
2550 | 2541 |
2551 | 2542 |
2552 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2543 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
2553 // Assignment to a property, using a named store IC. | 2544 // Assignment to a property, using a named store IC. |
2554 Property* prop = expr->target()->AsProperty(); | 2545 Property* prop = expr->target()->AsProperty(); |
2555 DCHECK(prop != NULL); | 2546 DCHECK(prop != NULL); |
2556 DCHECK(prop->key()->IsLiteral()); | 2547 DCHECK(prop->key()->IsLiteral()); |
2557 | 2548 |
2558 // Record source code position before IC call. | 2549 // Record source code position before IC call. |
2559 SetSourcePosition(expr->position()); | 2550 SetSourcePosition(expr->position()); |
2560 __ mov(StoreIC::NameRegister(), Operand(prop->key()->AsLiteral()->value())); | 2551 __ mov(StoreIC::NameRegister(), Operand(prop->key()->AsLiteral()->value())); |
2561 __ pop(StoreIC::ReceiverRegister()); | 2552 __ pop(StoreIC::ReceiverRegister()); |
2562 CallStoreIC(expr->AssignmentFeedbackId()); | 2553 CallStoreIC(expr->AssignmentFeedbackId()); |
2563 | 2554 |
2564 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2555 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2565 context()->Plug(r0); | 2556 context()->Plug(r3); |
2566 } | 2557 } |
2567 | 2558 |
2568 | 2559 |
2569 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2560 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
2570 // Assignment to a property, using a keyed store IC. | 2561 // Assignment to a property, using a keyed store IC. |
2571 | 2562 |
2572 // Record source code position before IC call. | 2563 // Record source code position before IC call. |
2573 SetSourcePosition(expr->position()); | 2564 SetSourcePosition(expr->position()); |
2574 __ Pop(KeyedStoreIC::ReceiverRegister(), KeyedStoreIC::NameRegister()); | 2565 __ Pop(KeyedStoreIC::ReceiverRegister(), KeyedStoreIC::NameRegister()); |
2575 DCHECK(KeyedStoreIC::ValueRegister().is(r0)); | 2566 DCHECK(KeyedStoreIC::ValueRegister().is(r3)); |
2576 | 2567 |
2577 Handle<Code> ic = strict_mode() == SLOPPY | 2568 Handle<Code> ic = |
2578 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2569 strict_mode() == SLOPPY |
2579 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2570 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 2571 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2580 CallIC(ic, expr->AssignmentFeedbackId()); | 2572 CallIC(ic, expr->AssignmentFeedbackId()); |
2581 | 2573 |
2582 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2574 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2583 context()->Plug(r0); | 2575 context()->Plug(r3); |
2584 } | 2576 } |
2585 | 2577 |
2586 | 2578 |
2587 void FullCodeGenerator::VisitProperty(Property* expr) { | 2579 void FullCodeGenerator::VisitProperty(Property* expr) { |
2588 Comment cmnt(masm_, "[ Property"); | 2580 Comment cmnt(masm_, "[ Property"); |
2589 Expression* key = expr->key(); | 2581 Expression* key = expr->key(); |
2590 | 2582 |
2591 if (key->IsPropertyName()) { | 2583 if (key->IsPropertyName()) { |
2592 VisitForAccumulatorValue(expr->obj()); | 2584 VisitForAccumulatorValue(expr->obj()); |
2593 __ Move(LoadIC::ReceiverRegister(), r0); | 2585 __ Move(LoadIC::ReceiverRegister(), r3); |
2594 EmitNamedPropertyLoad(expr); | 2586 EmitNamedPropertyLoad(expr); |
2595 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2587 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
2596 context()->Plug(r0); | 2588 context()->Plug(r3); |
2597 } else { | 2589 } else { |
2598 VisitForStackValue(expr->obj()); | 2590 VisitForStackValue(expr->obj()); |
2599 VisitForAccumulatorValue(expr->key()); | 2591 VisitForAccumulatorValue(expr->key()); |
2600 __ Move(LoadIC::NameRegister(), r0); | 2592 __ Move(LoadIC::NameRegister(), r3); |
2601 __ pop(LoadIC::ReceiverRegister()); | 2593 __ pop(LoadIC::ReceiverRegister()); |
2602 EmitKeyedPropertyLoad(expr); | 2594 EmitKeyedPropertyLoad(expr); |
2603 context()->Plug(r0); | 2595 context()->Plug(r3); |
2604 } | 2596 } |
2605 } | 2597 } |
2606 | 2598 |
2607 | 2599 |
2608 void FullCodeGenerator::CallIC(Handle<Code> code, | 2600 void FullCodeGenerator::CallIC(Handle<Code> code, TypeFeedbackId ast_id) { |
2609 TypeFeedbackId ast_id) { | |
2610 ic_total_count_++; | 2601 ic_total_count_++; |
2611 // All calls must have a predictable size in full-codegen code to ensure that | 2602 __ Call(code, RelocInfo::CODE_TARGET, ast_id); |
2612 // the debugger can patch them correctly. | |
2613 __ Call(code, RelocInfo::CODE_TARGET, ast_id, al, | |
2614 NEVER_INLINE_TARGET_ADDRESS); | |
2615 } | 2603 } |
2616 | 2604 |
2617 | 2605 |
2618 // Code common for calls using the IC. | 2606 // Code common for calls using the IC. |
2619 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { | 2607 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
2620 Expression* callee = expr->expression(); | 2608 Expression* callee = expr->expression(); |
2621 | 2609 |
2622 CallIC::CallType call_type = callee->IsVariableProxy() | 2610 CallIC::CallType call_type = |
2623 ? CallIC::FUNCTION | 2611 callee->IsVariableProxy() ? CallIC::FUNCTION : CallIC::METHOD; |
2624 : CallIC::METHOD; | |
2625 | 2612 |
2626 // Get the target function. | 2613 // Get the target function. |
2627 if (call_type == CallIC::FUNCTION) { | 2614 if (call_type == CallIC::FUNCTION) { |
2628 { StackValueContext context(this); | 2615 { |
| 2616 StackValueContext context(this); |
2629 EmitVariableLoad(callee->AsVariableProxy()); | 2617 EmitVariableLoad(callee->AsVariableProxy()); |
2630 PrepareForBailout(callee, NO_REGISTERS); | 2618 PrepareForBailout(callee, NO_REGISTERS); |
2631 } | 2619 } |
2632 // Push undefined as receiver. This is patched in the method prologue if it | 2620 // Push undefined as receiver. This is patched in the method prologue if it |
2633 // is a sloppy mode method. | 2621 // is a sloppy mode method. |
2634 __ Push(isolate()->factory()->undefined_value()); | 2622 __ Push(isolate()->factory()->undefined_value()); |
2635 } else { | 2623 } else { |
2636 // Load the function from the receiver. | 2624 // Load the function from the receiver. |
2637 DCHECK(callee->IsProperty()); | 2625 DCHECK(callee->IsProperty()); |
2638 __ ldr(LoadIC::ReceiverRegister(), MemOperand(sp, 0)); | 2626 __ LoadP(LoadIC::ReceiverRegister(), MemOperand(sp, 0)); |
2639 EmitNamedPropertyLoad(callee->AsProperty()); | 2627 EmitNamedPropertyLoad(callee->AsProperty()); |
2640 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2628 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
2641 // Push the target function under the receiver. | 2629 // Push the target function under the receiver. |
2642 __ ldr(ip, MemOperand(sp, 0)); | 2630 __ LoadP(ip, MemOperand(sp, 0)); |
2643 __ push(ip); | 2631 __ push(ip); |
2644 __ str(r0, MemOperand(sp, kPointerSize)); | 2632 __ StoreP(r3, MemOperand(sp, kPointerSize)); |
2645 } | 2633 } |
2646 | 2634 |
2647 EmitCall(expr, call_type); | 2635 EmitCall(expr, call_type); |
2648 } | 2636 } |
2649 | 2637 |
2650 | 2638 |
2651 // Code common for calls using the IC. | 2639 // Code common for calls using the IC. |
2652 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, | 2640 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, Expression* key) { |
2653 Expression* key) { | |
2654 // Load the key. | 2641 // Load the key. |
2655 VisitForAccumulatorValue(key); | 2642 VisitForAccumulatorValue(key); |
2656 | 2643 |
2657 Expression* callee = expr->expression(); | 2644 Expression* callee = expr->expression(); |
2658 | 2645 |
2659 // Load the function from the receiver. | 2646 // Load the function from the receiver. |
2660 DCHECK(callee->IsProperty()); | 2647 DCHECK(callee->IsProperty()); |
2661 __ ldr(LoadIC::ReceiverRegister(), MemOperand(sp, 0)); | 2648 __ LoadP(LoadIC::ReceiverRegister(), MemOperand(sp, 0)); |
2662 __ Move(LoadIC::NameRegister(), r0); | 2649 __ Move(LoadIC::NameRegister(), r3); |
2663 EmitKeyedPropertyLoad(callee->AsProperty()); | 2650 EmitKeyedPropertyLoad(callee->AsProperty()); |
2664 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2651 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
2665 | 2652 |
2666 // Push the target function under the receiver. | 2653 // Push the target function under the receiver. |
2667 __ ldr(ip, MemOperand(sp, 0)); | 2654 __ LoadP(ip, MemOperand(sp, 0)); |
2668 __ push(ip); | 2655 __ push(ip); |
2669 __ str(r0, MemOperand(sp, kPointerSize)); | 2656 __ StoreP(r3, MemOperand(sp, kPointerSize)); |
2670 | 2657 |
2671 EmitCall(expr, CallIC::METHOD); | 2658 EmitCall(expr, CallIC::METHOD); |
2672 } | 2659 } |
2673 | 2660 |
2674 | 2661 |
2675 void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) { | 2662 void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) { |
2676 // Load the arguments. | 2663 // Load the arguments. |
2677 ZoneList<Expression*>* args = expr->arguments(); | 2664 ZoneList<Expression*>* args = expr->arguments(); |
2678 int arg_count = args->length(); | 2665 int arg_count = args->length(); |
2679 { PreservePositionScope scope(masm()->positions_recorder()); | 2666 { |
| 2667 PreservePositionScope scope(masm()->positions_recorder()); |
2680 for (int i = 0; i < arg_count; i++) { | 2668 for (int i = 0; i < arg_count; i++) { |
2681 VisitForStackValue(args->at(i)); | 2669 VisitForStackValue(args->at(i)); |
2682 } | 2670 } |
2683 } | 2671 } |
2684 | 2672 |
2685 // Record source position of the IC call. | 2673 // Record source position of the IC call. |
2686 SetSourcePosition(expr->position()); | 2674 SetSourcePosition(expr->position()); |
2687 Handle<Code> ic = CallIC::initialize_stub( | 2675 Handle<Code> ic = CallIC::initialize_stub(isolate(), arg_count, call_type); |
2688 isolate(), arg_count, call_type); | 2676 __ LoadSmiLiteral(r6, Smi::FromInt(expr->CallFeedbackSlot())); |
2689 __ mov(r3, Operand(Smi::FromInt(expr->CallFeedbackSlot()))); | 2677 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
2690 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
2691 // Don't assign a type feedback id to the IC, since type feedback is provided | 2678 // Don't assign a type feedback id to the IC, since type feedback is provided |
2692 // by the vector above. | 2679 // by the vector above. |
2693 CallIC(ic); | 2680 CallIC(ic); |
2694 | 2681 |
2695 RecordJSReturnSite(expr); | 2682 RecordJSReturnSite(expr); |
2696 // Restore context register. | 2683 // Restore context register. |
2697 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2684 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2698 context()->DropAndPlug(1, r0); | 2685 context()->DropAndPlug(1, r3); |
2699 } | 2686 } |
2700 | 2687 |
2701 | 2688 |
2702 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2689 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
2703 // r4: copy of the first argument or undefined if it doesn't exist. | 2690 // r7: copy of the first argument or undefined if it doesn't exist. |
2704 if (arg_count > 0) { | 2691 if (arg_count > 0) { |
2705 __ ldr(r4, MemOperand(sp, arg_count * kPointerSize)); | 2692 __ LoadP(r7, MemOperand(sp, arg_count * kPointerSize), r0); |
2706 } else { | 2693 } else { |
2707 __ LoadRoot(r4, Heap::kUndefinedValueRootIndex); | 2694 __ LoadRoot(r7, Heap::kUndefinedValueRootIndex); |
2708 } | 2695 } |
2709 | 2696 |
2710 // r3: the receiver of the enclosing function. | 2697 // r6: the receiver of the enclosing function. |
2711 int receiver_offset = 2 + info_->scope()->num_parameters(); | 2698 int receiver_offset = 2 + info_->scope()->num_parameters(); |
2712 __ ldr(r3, MemOperand(fp, receiver_offset * kPointerSize)); | 2699 __ LoadP(r6, MemOperand(fp, receiver_offset * kPointerSize), r0); |
2713 | 2700 |
2714 // r2: strict mode. | 2701 // r5: strict mode. |
2715 __ mov(r2, Operand(Smi::FromInt(strict_mode()))); | 2702 __ LoadSmiLiteral(r5, Smi::FromInt(strict_mode())); |
2716 | 2703 |
2717 // r1: the start position of the scope the calls resides in. | 2704 // r4: the start position of the scope the calls resides in. |
2718 __ mov(r1, Operand(Smi::FromInt(scope()->start_position()))); | 2705 __ LoadSmiLiteral(r4, Smi::FromInt(scope()->start_position())); |
2719 | 2706 |
2720 // Do the runtime call. | 2707 // Do the runtime call. |
2721 __ Push(r4, r3, r2, r1); | 2708 __ Push(r7, r6, r5, r4); |
2722 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); | 2709 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); |
2723 } | 2710 } |
2724 | 2711 |
2725 | 2712 |
2726 void FullCodeGenerator::VisitCall(Call* expr) { | 2713 void FullCodeGenerator::VisitCall(Call* expr) { |
2727 #ifdef DEBUG | 2714 #ifdef DEBUG |
2728 // We want to verify that RecordJSReturnSite gets called on all paths | 2715 // We want to verify that RecordJSReturnSite gets called on all paths |
2729 // through this function. Avoid early returns. | 2716 // through this function. Avoid early returns. |
2730 expr->return_is_recorded_ = false; | 2717 expr->return_is_recorded_ = false; |
2731 #endif | 2718 #endif |
2732 | 2719 |
2733 Comment cmnt(masm_, "[ Call"); | 2720 Comment cmnt(masm_, "[ Call"); |
2734 Expression* callee = expr->expression(); | 2721 Expression* callee = expr->expression(); |
2735 Call::CallType call_type = expr->GetCallType(isolate()); | 2722 Call::CallType call_type = expr->GetCallType(isolate()); |
2736 | 2723 |
2737 if (call_type == Call::POSSIBLY_EVAL_CALL) { | 2724 if (call_type == Call::POSSIBLY_EVAL_CALL) { |
2738 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | 2725 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
2739 // to resolve the function we need to call and the receiver of the | 2726 // to resolve the function we need to call and the receiver of the |
2740 // call. Then we call the resolved function using the given | 2727 // call. Then we call the resolved function using the given |
2741 // arguments. | 2728 // arguments. |
2742 ZoneList<Expression*>* args = expr->arguments(); | 2729 ZoneList<Expression*>* args = expr->arguments(); |
2743 int arg_count = args->length(); | 2730 int arg_count = args->length(); |
2744 | 2731 |
2745 { PreservePositionScope pos_scope(masm()->positions_recorder()); | 2732 { |
| 2733 PreservePositionScope pos_scope(masm()->positions_recorder()); |
2746 VisitForStackValue(callee); | 2734 VisitForStackValue(callee); |
2747 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 2735 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
2748 __ push(r2); // Reserved receiver slot. | 2736 __ push(r5); // Reserved receiver slot. |
2749 | 2737 |
2750 // Push the arguments. | 2738 // Push the arguments. |
2751 for (int i = 0; i < arg_count; i++) { | 2739 for (int i = 0; i < arg_count; i++) { |
2752 VisitForStackValue(args->at(i)); | 2740 VisitForStackValue(args->at(i)); |
2753 } | 2741 } |
2754 | 2742 |
2755 // Push a copy of the function (found below the arguments) and | 2743 // Push a copy of the function (found below the arguments) and |
2756 // resolve eval. | 2744 // resolve eval. |
2757 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2745 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
2758 __ push(r1); | 2746 __ push(r4); |
2759 EmitResolvePossiblyDirectEval(arg_count); | 2747 EmitResolvePossiblyDirectEval(arg_count); |
2760 | 2748 |
2761 // The runtime call returns a pair of values in r0 (function) and | 2749 // The runtime call returns a pair of values in r3 (function) and |
2762 // r1 (receiver). Touch up the stack with the right values. | 2750 // r4 (receiver). Touch up the stack with the right values. |
2763 __ str(r0, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2751 __ StoreP(r3, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
2764 __ str(r1, MemOperand(sp, arg_count * kPointerSize)); | 2752 __ StoreP(r4, MemOperand(sp, arg_count * kPointerSize), r0); |
2765 } | 2753 } |
2766 | 2754 |
2767 // Record source position for debugger. | 2755 // Record source position for debugger. |
2768 SetSourcePosition(expr->position()); | 2756 SetSourcePosition(expr->position()); |
2769 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 2757 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
2770 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2758 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
2771 __ CallStub(&stub); | 2759 __ CallStub(&stub); |
2772 RecordJSReturnSite(expr); | 2760 RecordJSReturnSite(expr); |
2773 // Restore context register. | 2761 // Restore context register. |
2774 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2762 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2775 context()->DropAndPlug(1, r0); | 2763 context()->DropAndPlug(1, r3); |
2776 } else if (call_type == Call::GLOBAL_CALL) { | 2764 } else if (call_type == Call::GLOBAL_CALL) { |
2777 EmitCallWithLoadIC(expr); | 2765 EmitCallWithLoadIC(expr); |
2778 | 2766 |
2779 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | 2767 } else if (call_type == Call::LOOKUP_SLOT_CALL) { |
2780 // Call to a lookup slot (dynamically introduced variable). | 2768 // Call to a lookup slot (dynamically introduced variable). |
2781 VariableProxy* proxy = callee->AsVariableProxy(); | 2769 VariableProxy* proxy = callee->AsVariableProxy(); |
2782 Label slow, done; | 2770 Label slow, done; |
2783 | 2771 |
2784 { PreservePositionScope scope(masm()->positions_recorder()); | 2772 { |
| 2773 PreservePositionScope scope(masm()->positions_recorder()); |
2785 // Generate code for loading from variables potentially shadowed | 2774 // Generate code for loading from variables potentially shadowed |
2786 // by eval-introduced variables. | 2775 // by eval-introduced variables. |
2787 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); | 2776 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); |
2788 } | 2777 } |
2789 | 2778 |
2790 __ bind(&slow); | 2779 __ bind(&slow); |
2791 // Call the runtime to find the function to call (returned in r0) | 2780 // Call the runtime to find the function to call (returned in r3) |
2792 // and the object holding it (returned in edx). | 2781 // and the object holding it (returned in edx). |
2793 DCHECK(!context_register().is(r2)); | 2782 DCHECK(!context_register().is(r5)); |
2794 __ mov(r2, Operand(proxy->name())); | 2783 __ mov(r5, Operand(proxy->name())); |
2795 __ Push(context_register(), r2); | 2784 __ Push(context_register(), r5); |
2796 __ CallRuntime(Runtime::kLoadLookupSlot, 2); | 2785 __ CallRuntime(Runtime::kLoadLookupSlot, 2); |
2797 __ Push(r0, r1); // Function, receiver. | 2786 __ Push(r3, r4); // Function, receiver. |
2798 | 2787 |
2799 // If fast case code has been generated, emit code to push the | 2788 // If fast case code has been generated, emit code to push the |
2800 // function and receiver and have the slow path jump around this | 2789 // function and receiver and have the slow path jump around this |
2801 // code. | 2790 // code. |
2802 if (done.is_linked()) { | 2791 if (done.is_linked()) { |
2803 Label call; | 2792 Label call; |
2804 __ b(&call); | 2793 __ b(&call); |
2805 __ bind(&done); | 2794 __ bind(&done); |
2806 // Push function. | 2795 // Push function. |
2807 __ push(r0); | 2796 __ push(r3); |
2808 // The receiver is implicitly the global receiver. Indicate this | 2797 // The receiver is implicitly the global receiver. Indicate this |
2809 // by passing the hole to the call function stub. | 2798 // by passing the hole to the call function stub. |
2810 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); | 2799 __ LoadRoot(r4, Heap::kUndefinedValueRootIndex); |
2811 __ push(r1); | 2800 __ push(r4); |
2812 __ bind(&call); | 2801 __ bind(&call); |
2813 } | 2802 } |
2814 | 2803 |
2815 // The receiver is either the global receiver or an object found | 2804 // The receiver is either the global receiver or an object found |
2816 // by LoadContextSlot. | 2805 // by LoadContextSlot. |
2817 EmitCall(expr); | 2806 EmitCall(expr); |
2818 } else if (call_type == Call::PROPERTY_CALL) { | 2807 } else if (call_type == Call::PROPERTY_CALL) { |
2819 Property* property = callee->AsProperty(); | 2808 Property* property = callee->AsProperty(); |
2820 { PreservePositionScope scope(masm()->positions_recorder()); | 2809 { |
| 2810 PreservePositionScope scope(masm()->positions_recorder()); |
2821 VisitForStackValue(property->obj()); | 2811 VisitForStackValue(property->obj()); |
2822 } | 2812 } |
2823 if (property->key()->IsPropertyName()) { | 2813 if (property->key()->IsPropertyName()) { |
2824 EmitCallWithLoadIC(expr); | 2814 EmitCallWithLoadIC(expr); |
2825 } else { | 2815 } else { |
2826 EmitKeyedCallWithLoadIC(expr, property->key()); | 2816 EmitKeyedCallWithLoadIC(expr, property->key()); |
2827 } | 2817 } |
2828 } else { | 2818 } else { |
2829 DCHECK(call_type == Call::OTHER_CALL); | 2819 DCHECK(call_type == Call::OTHER_CALL); |
2830 // Call to an arbitrary expression not handled specially above. | 2820 // Call to an arbitrary expression not handled specially above. |
2831 { PreservePositionScope scope(masm()->positions_recorder()); | 2821 { |
| 2822 PreservePositionScope scope(masm()->positions_recorder()); |
2832 VisitForStackValue(callee); | 2823 VisitForStackValue(callee); |
2833 } | 2824 } |
2834 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); | 2825 __ LoadRoot(r4, Heap::kUndefinedValueRootIndex); |
2835 __ push(r1); | 2826 __ push(r4); |
2836 // Emit function call. | 2827 // Emit function call. |
2837 EmitCall(expr); | 2828 EmitCall(expr); |
2838 } | 2829 } |
2839 | 2830 |
2840 #ifdef DEBUG | 2831 #ifdef DEBUG |
2841 // RecordJSReturnSite should have been called. | 2832 // RecordJSReturnSite should have been called. |
2842 DCHECK(expr->return_is_recorded_); | 2833 DCHECK(expr->return_is_recorded_); |
2843 #endif | 2834 #endif |
2844 } | 2835 } |
2845 | 2836 |
(...skipping 13 matching lines...) Expand all Loading... |
2859 ZoneList<Expression*>* args = expr->arguments(); | 2850 ZoneList<Expression*>* args = expr->arguments(); |
2860 int arg_count = args->length(); | 2851 int arg_count = args->length(); |
2861 for (int i = 0; i < arg_count; i++) { | 2852 for (int i = 0; i < arg_count; i++) { |
2862 VisitForStackValue(args->at(i)); | 2853 VisitForStackValue(args->at(i)); |
2863 } | 2854 } |
2864 | 2855 |
2865 // Call the construct call builtin that handles allocation and | 2856 // Call the construct call builtin that handles allocation and |
2866 // constructor invocation. | 2857 // constructor invocation. |
2867 SetSourcePosition(expr->position()); | 2858 SetSourcePosition(expr->position()); |
2868 | 2859 |
2869 // Load function and argument count into r1 and r0. | 2860 // Load function and argument count into r4 and r3. |
2870 __ mov(r0, Operand(arg_count)); | 2861 __ mov(r3, Operand(arg_count)); |
2871 __ ldr(r1, MemOperand(sp, arg_count * kPointerSize)); | 2862 __ LoadP(r4, MemOperand(sp, arg_count * kPointerSize), r0); |
2872 | 2863 |
2873 // Record call targets in unoptimized code. | 2864 // Record call targets in unoptimized code. |
2874 if (FLAG_pretenuring_call_new) { | 2865 if (FLAG_pretenuring_call_new) { |
2875 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 2866 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
2876 DCHECK(expr->AllocationSiteFeedbackSlot() == | 2867 DCHECK(expr->AllocationSiteFeedbackSlot() == |
2877 expr->CallNewFeedbackSlot() + 1); | 2868 expr->CallNewFeedbackSlot() + 1); |
2878 } | 2869 } |
2879 | 2870 |
2880 __ Move(r2, FeedbackVector()); | 2871 __ Move(r5, FeedbackVector()); |
2881 __ mov(r3, Operand(Smi::FromInt(expr->CallNewFeedbackSlot()))); | 2872 __ LoadSmiLiteral(r6, Smi::FromInt(expr->CallNewFeedbackSlot())); |
2882 | 2873 |
2883 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 2874 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
2884 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 2875 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
2885 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2876 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
2886 context()->Plug(r0); | 2877 context()->Plug(r3); |
2887 } | 2878 } |
2888 | 2879 |
2889 | 2880 |
2890 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 2881 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
2891 ZoneList<Expression*>* args = expr->arguments(); | 2882 ZoneList<Expression*>* args = expr->arguments(); |
2892 DCHECK(args->length() == 1); | 2883 DCHECK(args->length() == 1); |
2893 | 2884 |
2894 VisitForAccumulatorValue(args->at(0)); | 2885 VisitForAccumulatorValue(args->at(0)); |
2895 | 2886 |
2896 Label materialize_true, materialize_false; | 2887 Label materialize_true, materialize_false; |
2897 Label* if_true = NULL; | 2888 Label* if_true = NULL; |
2898 Label* if_false = NULL; | 2889 Label* if_false = NULL; |
2899 Label* fall_through = NULL; | 2890 Label* fall_through = NULL; |
2900 context()->PrepareTest(&materialize_true, &materialize_false, | 2891 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
2901 &if_true, &if_false, &fall_through); | 2892 &if_false, &fall_through); |
2902 | 2893 |
2903 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 2894 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
2904 __ SmiTst(r0); | 2895 __ TestIfSmi(r3, r0); |
2905 Split(eq, if_true, if_false, fall_through); | 2896 Split(eq, if_true, if_false, fall_through, cr0); |
2906 | 2897 |
2907 context()->Plug(if_true, if_false); | 2898 context()->Plug(if_true, if_false); |
2908 } | 2899 } |
2909 | 2900 |
2910 | 2901 |
2911 void FullCodeGenerator::EmitIsNonNegativeSmi(CallRuntime* expr) { | 2902 void FullCodeGenerator::EmitIsNonNegativeSmi(CallRuntime* expr) { |
2912 ZoneList<Expression*>* args = expr->arguments(); | 2903 ZoneList<Expression*>* args = expr->arguments(); |
2913 DCHECK(args->length() == 1); | 2904 DCHECK(args->length() == 1); |
2914 | 2905 |
2915 VisitForAccumulatorValue(args->at(0)); | 2906 VisitForAccumulatorValue(args->at(0)); |
2916 | 2907 |
2917 Label materialize_true, materialize_false; | 2908 Label materialize_true, materialize_false; |
2918 Label* if_true = NULL; | 2909 Label* if_true = NULL; |
2919 Label* if_false = NULL; | 2910 Label* if_false = NULL; |
2920 Label* fall_through = NULL; | 2911 Label* fall_through = NULL; |
2921 context()->PrepareTest(&materialize_true, &materialize_false, | 2912 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
2922 &if_true, &if_false, &fall_through); | 2913 &if_false, &fall_through); |
2923 | 2914 |
2924 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 2915 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
2925 __ NonNegativeSmiTst(r0); | 2916 __ TestIfPositiveSmi(r3, r0); |
2926 Split(eq, if_true, if_false, fall_through); | 2917 Split(eq, if_true, if_false, fall_through, cr0); |
2927 | 2918 |
2928 context()->Plug(if_true, if_false); | 2919 context()->Plug(if_true, if_false); |
2929 } | 2920 } |
2930 | 2921 |
2931 | 2922 |
2932 void FullCodeGenerator::EmitIsObject(CallRuntime* expr) { | 2923 void FullCodeGenerator::EmitIsObject(CallRuntime* expr) { |
2933 ZoneList<Expression*>* args = expr->arguments(); | 2924 ZoneList<Expression*>* args = expr->arguments(); |
2934 DCHECK(args->length() == 1); | 2925 DCHECK(args->length() == 1); |
2935 | 2926 |
2936 VisitForAccumulatorValue(args->at(0)); | 2927 VisitForAccumulatorValue(args->at(0)); |
2937 | 2928 |
2938 Label materialize_true, materialize_false; | 2929 Label materialize_true, materialize_false; |
2939 Label* if_true = NULL; | 2930 Label* if_true = NULL; |
2940 Label* if_false = NULL; | 2931 Label* if_false = NULL; |
2941 Label* fall_through = NULL; | 2932 Label* fall_through = NULL; |
2942 context()->PrepareTest(&materialize_true, &materialize_false, | 2933 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
2943 &if_true, &if_false, &fall_through); | 2934 &if_false, &fall_through); |
2944 | 2935 |
2945 __ JumpIfSmi(r0, if_false); | 2936 __ JumpIfSmi(r3, if_false); |
2946 __ LoadRoot(ip, Heap::kNullValueRootIndex); | 2937 __ LoadRoot(ip, Heap::kNullValueRootIndex); |
2947 __ cmp(r0, ip); | 2938 __ cmp(r3, ip); |
2948 __ b(eq, if_true); | 2939 __ beq(if_true); |
2949 __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); | 2940 __ LoadP(r5, FieldMemOperand(r3, HeapObject::kMapOffset)); |
2950 // Undetectable objects behave like undefined when tested with typeof. | 2941 // Undetectable objects behave like undefined when tested with typeof. |
2951 __ ldrb(r1, FieldMemOperand(r2, Map::kBitFieldOffset)); | 2942 __ lbz(r4, FieldMemOperand(r5, Map::kBitFieldOffset)); |
2952 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | 2943 __ andi(r0, r4, Operand(1 << Map::kIsUndetectable)); |
2953 __ b(ne, if_false); | 2944 __ bne(if_false, cr0); |
2954 __ ldrb(r1, FieldMemOperand(r2, Map::kInstanceTypeOffset)); | 2945 __ lbz(r4, FieldMemOperand(r5, Map::kInstanceTypeOffset)); |
2955 __ cmp(r1, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); | 2946 __ cmpi(r4, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
2956 __ b(lt, if_false); | 2947 __ blt(if_false); |
2957 __ cmp(r1, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); | 2948 __ cmpi(r4, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
2958 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 2949 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
2959 Split(le, if_true, if_false, fall_through); | 2950 Split(le, if_true, if_false, fall_through); |
2960 | 2951 |
2961 context()->Plug(if_true, if_false); | 2952 context()->Plug(if_true, if_false); |
2962 } | 2953 } |
2963 | 2954 |
2964 | 2955 |
2965 void FullCodeGenerator::EmitIsSpecObject(CallRuntime* expr) { | 2956 void FullCodeGenerator::EmitIsSpecObject(CallRuntime* expr) { |
2966 ZoneList<Expression*>* args = expr->arguments(); | 2957 ZoneList<Expression*>* args = expr->arguments(); |
2967 DCHECK(args->length() == 1); | 2958 DCHECK(args->length() == 1); |
2968 | 2959 |
2969 VisitForAccumulatorValue(args->at(0)); | 2960 VisitForAccumulatorValue(args->at(0)); |
2970 | 2961 |
2971 Label materialize_true, materialize_false; | 2962 Label materialize_true, materialize_false; |
2972 Label* if_true = NULL; | 2963 Label* if_true = NULL; |
2973 Label* if_false = NULL; | 2964 Label* if_false = NULL; |
2974 Label* fall_through = NULL; | 2965 Label* fall_through = NULL; |
2975 context()->PrepareTest(&materialize_true, &materialize_false, | 2966 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
2976 &if_true, &if_false, &fall_through); | 2967 &if_false, &fall_through); |
2977 | 2968 |
2978 __ JumpIfSmi(r0, if_false); | 2969 __ JumpIfSmi(r3, if_false); |
2979 __ CompareObjectType(r0, r1, r1, FIRST_SPEC_OBJECT_TYPE); | 2970 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); |
2980 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 2971 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
2981 Split(ge, if_true, if_false, fall_through); | 2972 Split(ge, if_true, if_false, fall_through); |
2982 | 2973 |
2983 context()->Plug(if_true, if_false); | 2974 context()->Plug(if_true, if_false); |
2984 } | 2975 } |
2985 | 2976 |
2986 | 2977 |
2987 void FullCodeGenerator::EmitIsUndetectableObject(CallRuntime* expr) { | 2978 void FullCodeGenerator::EmitIsUndetectableObject(CallRuntime* expr) { |
2988 ZoneList<Expression*>* args = expr->arguments(); | 2979 ZoneList<Expression*>* args = expr->arguments(); |
2989 DCHECK(args->length() == 1); | 2980 DCHECK(args->length() == 1); |
2990 | 2981 |
2991 VisitForAccumulatorValue(args->at(0)); | 2982 VisitForAccumulatorValue(args->at(0)); |
2992 | 2983 |
2993 Label materialize_true, materialize_false; | 2984 Label materialize_true, materialize_false; |
2994 Label* if_true = NULL; | 2985 Label* if_true = NULL; |
2995 Label* if_false = NULL; | 2986 Label* if_false = NULL; |
2996 Label* fall_through = NULL; | 2987 Label* fall_through = NULL; |
2997 context()->PrepareTest(&materialize_true, &materialize_false, | 2988 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
2998 &if_true, &if_false, &fall_through); | 2989 &if_false, &fall_through); |
2999 | 2990 |
3000 __ JumpIfSmi(r0, if_false); | 2991 __ JumpIfSmi(r3, if_false); |
3001 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | 2992 __ LoadP(r4, FieldMemOperand(r3, HeapObject::kMapOffset)); |
3002 __ ldrb(r1, FieldMemOperand(r1, Map::kBitFieldOffset)); | 2993 __ lbz(r4, FieldMemOperand(r4, Map::kBitFieldOffset)); |
3003 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | 2994 __ andi(r0, r4, Operand(1 << Map::kIsUndetectable)); |
3004 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 2995 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3005 Split(ne, if_true, if_false, fall_through); | 2996 Split(ne, if_true, if_false, fall_through, cr0); |
3006 | 2997 |
3007 context()->Plug(if_true, if_false); | 2998 context()->Plug(if_true, if_false); |
3008 } | 2999 } |
3009 | 3000 |
3010 | 3001 |
3011 void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( | 3002 void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( |
3012 CallRuntime* expr) { | 3003 CallRuntime* expr) { |
3013 ZoneList<Expression*>* args = expr->arguments(); | 3004 ZoneList<Expression*>* args = expr->arguments(); |
3014 DCHECK(args->length() == 1); | 3005 DCHECK(args->length() == 1); |
3015 | 3006 |
3016 VisitForAccumulatorValue(args->at(0)); | 3007 VisitForAccumulatorValue(args->at(0)); |
3017 | 3008 |
3018 Label materialize_true, materialize_false, skip_lookup; | 3009 Label materialize_true, materialize_false, skip_lookup; |
3019 Label* if_true = NULL; | 3010 Label* if_true = NULL; |
3020 Label* if_false = NULL; | 3011 Label* if_false = NULL; |
3021 Label* fall_through = NULL; | 3012 Label* fall_through = NULL; |
3022 context()->PrepareTest(&materialize_true, &materialize_false, | 3013 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
3023 &if_true, &if_false, &fall_through); | 3014 &if_false, &fall_through); |
3024 | 3015 |
3025 __ AssertNotSmi(r0); | 3016 __ AssertNotSmi(r3); |
3026 | 3017 |
3027 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | 3018 __ LoadP(r4, FieldMemOperand(r3, HeapObject::kMapOffset)); |
3028 __ ldrb(ip, FieldMemOperand(r1, Map::kBitField2Offset)); | 3019 __ lbz(ip, FieldMemOperand(r4, Map::kBitField2Offset)); |
3029 __ tst(ip, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf)); | 3020 __ andi(r0, ip, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
3030 __ b(ne, &skip_lookup); | 3021 __ bne(&skip_lookup, cr0); |
3031 | 3022 |
3032 // Check for fast case object. Generate false result for slow case object. | 3023 // Check for fast case object. Generate false result for slow case object. |
3033 __ ldr(r2, FieldMemOperand(r0, JSObject::kPropertiesOffset)); | 3024 __ LoadP(r5, FieldMemOperand(r3, JSObject::kPropertiesOffset)); |
3034 __ ldr(r2, FieldMemOperand(r2, HeapObject::kMapOffset)); | 3025 __ LoadP(r5, FieldMemOperand(r5, HeapObject::kMapOffset)); |
3035 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); | 3026 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); |
3036 __ cmp(r2, ip); | 3027 __ cmp(r5, ip); |
3037 __ b(eq, if_false); | 3028 __ beq(if_false); |
3038 | 3029 |
3039 // Look for valueOf name in the descriptor array, and indicate false if | 3030 // Look for valueOf name in the descriptor array, and indicate false if |
3040 // found. Since we omit an enumeration index check, if it is added via a | 3031 // found. Since we omit an enumeration index check, if it is added via a |
3041 // transition that shares its descriptor array, this is a false positive. | 3032 // transition that shares its descriptor array, this is a false positive. |
3042 Label entry, loop, done; | 3033 Label entry, loop, done; |
3043 | 3034 |
3044 // Skip loop if no descriptors are valid. | 3035 // Skip loop if no descriptors are valid. |
3045 __ NumberOfOwnDescriptors(r3, r1); | 3036 __ NumberOfOwnDescriptors(r6, r4); |
3046 __ cmp(r3, Operand::Zero()); | 3037 __ cmpi(r6, Operand::Zero()); |
3047 __ b(eq, &done); | 3038 __ beq(&done); |
3048 | 3039 |
3049 __ LoadInstanceDescriptors(r1, r4); | 3040 __ LoadInstanceDescriptors(r4, r7); |
3050 // r4: descriptor array. | 3041 // r7: descriptor array. |
3051 // r3: valid entries in the descriptor array. | 3042 // r6: valid entries in the descriptor array. |
3052 __ mov(ip, Operand(DescriptorArray::kDescriptorSize)); | 3043 __ mov(ip, Operand(DescriptorArray::kDescriptorSize)); |
3053 __ mul(r3, r3, ip); | 3044 __ Mul(r6, r6, ip); |
3054 // Calculate location of the first key name. | 3045 // Calculate location of the first key name. |
3055 __ add(r4, r4, Operand(DescriptorArray::kFirstOffset - kHeapObjectTag)); | 3046 __ addi(r7, r7, Operand(DescriptorArray::kFirstOffset - kHeapObjectTag)); |
3056 // Calculate the end of the descriptor array. | 3047 // Calculate the end of the descriptor array. |
3057 __ mov(r2, r4); | 3048 __ mr(r5, r7); |
3058 __ add(r2, r2, Operand(r3, LSL, kPointerSizeLog2)); | 3049 __ ShiftLeftImm(ip, r6, Operand(kPointerSizeLog2)); |
| 3050 __ add(r5, r5, ip); |
3059 | 3051 |
3060 // Loop through all the keys in the descriptor array. If one of these is the | 3052 // Loop through all the keys in the descriptor array. If one of these is the |
3061 // string "valueOf" the result is false. | 3053 // string "valueOf" the result is false. |
3062 // The use of ip to store the valueOf string assumes that it is not otherwise | 3054 // The use of ip to store the valueOf string assumes that it is not otherwise |
3063 // used in the loop below. | 3055 // used in the loop below. |
3064 __ mov(ip, Operand(isolate()->factory()->value_of_string())); | 3056 __ mov(ip, Operand(isolate()->factory()->value_of_string())); |
3065 __ jmp(&entry); | 3057 __ b(&entry); |
3066 __ bind(&loop); | 3058 __ bind(&loop); |
3067 __ ldr(r3, MemOperand(r4, 0)); | 3059 __ LoadP(r6, MemOperand(r7, 0)); |
3068 __ cmp(r3, ip); | 3060 __ cmp(r6, ip); |
3069 __ b(eq, if_false); | 3061 __ beq(if_false); |
3070 __ add(r4, r4, Operand(DescriptorArray::kDescriptorSize * kPointerSize)); | 3062 __ addi(r7, r7, Operand(DescriptorArray::kDescriptorSize * kPointerSize)); |
3071 __ bind(&entry); | 3063 __ bind(&entry); |
3072 __ cmp(r4, Operand(r2)); | 3064 __ cmp(r7, r5); |
3073 __ b(ne, &loop); | 3065 __ bne(&loop); |
3074 | 3066 |
3075 __ bind(&done); | 3067 __ bind(&done); |
3076 | 3068 |
3077 // Set the bit in the map to indicate that there is no local valueOf field. | 3069 // Set the bit in the map to indicate that there is no local valueOf field. |
3078 __ ldrb(r2, FieldMemOperand(r1, Map::kBitField2Offset)); | 3070 __ lbz(r5, FieldMemOperand(r4, Map::kBitField2Offset)); |
3079 __ orr(r2, r2, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf)); | 3071 __ ori(r5, r5, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
3080 __ strb(r2, FieldMemOperand(r1, Map::kBitField2Offset)); | 3072 __ stb(r5, FieldMemOperand(r4, Map::kBitField2Offset)); |
3081 | 3073 |
3082 __ bind(&skip_lookup); | 3074 __ bind(&skip_lookup); |
3083 | 3075 |
3084 // If a valueOf property is not found on the object check that its | 3076 // If a valueOf property is not found on the object check that its |
3085 // prototype is the un-modified String prototype. If not result is false. | 3077 // prototype is the un-modified String prototype. If not result is false. |
3086 __ ldr(r2, FieldMemOperand(r1, Map::kPrototypeOffset)); | 3078 __ LoadP(r5, FieldMemOperand(r4, Map::kPrototypeOffset)); |
3087 __ JumpIfSmi(r2, if_false); | 3079 __ JumpIfSmi(r5, if_false); |
3088 __ ldr(r2, FieldMemOperand(r2, HeapObject::kMapOffset)); | 3080 __ LoadP(r5, FieldMemOperand(r5, HeapObject::kMapOffset)); |
3089 __ ldr(r3, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); | 3081 __ LoadP(r6, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); |
3090 __ ldr(r3, FieldMemOperand(r3, GlobalObject::kNativeContextOffset)); | 3082 __ LoadP(r6, FieldMemOperand(r6, GlobalObject::kNativeContextOffset)); |
3091 __ ldr(r3, ContextOperand(r3, Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); | 3083 __ LoadP(r6, |
3092 __ cmp(r2, r3); | 3084 ContextOperand(r6, Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); |
| 3085 __ cmp(r5, r6); |
3093 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3086 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3094 Split(eq, if_true, if_false, fall_through); | 3087 Split(eq, if_true, if_false, fall_through); |
3095 | 3088 |
3096 context()->Plug(if_true, if_false); | 3089 context()->Plug(if_true, if_false); |
3097 } | 3090 } |
3098 | 3091 |
3099 | 3092 |
3100 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { | 3093 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { |
3101 ZoneList<Expression*>* args = expr->arguments(); | 3094 ZoneList<Expression*>* args = expr->arguments(); |
3102 DCHECK(args->length() == 1); | 3095 DCHECK(args->length() == 1); |
3103 | 3096 |
3104 VisitForAccumulatorValue(args->at(0)); | 3097 VisitForAccumulatorValue(args->at(0)); |
3105 | 3098 |
3106 Label materialize_true, materialize_false; | 3099 Label materialize_true, materialize_false; |
3107 Label* if_true = NULL; | 3100 Label* if_true = NULL; |
3108 Label* if_false = NULL; | 3101 Label* if_false = NULL; |
3109 Label* fall_through = NULL; | 3102 Label* fall_through = NULL; |
3110 context()->PrepareTest(&materialize_true, &materialize_false, | 3103 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
3111 &if_true, &if_false, &fall_through); | 3104 &if_false, &fall_through); |
3112 | 3105 |
3113 __ JumpIfSmi(r0, if_false); | 3106 __ JumpIfSmi(r3, if_false); |
3114 __ CompareObjectType(r0, r1, r2, JS_FUNCTION_TYPE); | 3107 __ CompareObjectType(r3, r4, r5, JS_FUNCTION_TYPE); |
3115 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3108 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3116 Split(eq, if_true, if_false, fall_through); | 3109 Split(eq, if_true, if_false, fall_through); |
3117 | 3110 |
3118 context()->Plug(if_true, if_false); | 3111 context()->Plug(if_true, if_false); |
3119 } | 3112 } |
3120 | 3113 |
3121 | 3114 |
3122 void FullCodeGenerator::EmitIsMinusZero(CallRuntime* expr) { | 3115 void FullCodeGenerator::EmitIsMinusZero(CallRuntime* expr) { |
3123 ZoneList<Expression*>* args = expr->arguments(); | 3116 ZoneList<Expression*>* args = expr->arguments(); |
3124 DCHECK(args->length() == 1); | 3117 DCHECK(args->length() == 1); |
3125 | 3118 |
3126 VisitForAccumulatorValue(args->at(0)); | 3119 VisitForAccumulatorValue(args->at(0)); |
3127 | 3120 |
3128 Label materialize_true, materialize_false; | 3121 Label materialize_true, materialize_false; |
3129 Label* if_true = NULL; | 3122 Label* if_true = NULL; |
3130 Label* if_false = NULL; | 3123 Label* if_false = NULL; |
3131 Label* fall_through = NULL; | 3124 Label* fall_through = NULL; |
3132 context()->PrepareTest(&materialize_true, &materialize_false, | 3125 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
3133 &if_true, &if_false, &fall_through); | 3126 &if_false, &fall_through); |
3134 | 3127 |
3135 __ CheckMap(r0, r1, Heap::kHeapNumberMapRootIndex, if_false, DO_SMI_CHECK); | 3128 __ CheckMap(r3, r4, Heap::kHeapNumberMapRootIndex, if_false, DO_SMI_CHECK); |
3136 __ ldr(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset)); | 3129 #if V8_TARGET_ARCH_PPC64 |
3137 __ ldr(r1, FieldMemOperand(r0, HeapNumber::kMantissaOffset)); | 3130 __ LoadP(r4, FieldMemOperand(r3, HeapNumber::kValueOffset)); |
3138 __ cmp(r2, Operand(0x80000000)); | 3131 __ li(r5, Operand(1)); |
3139 __ cmp(r1, Operand(0x00000000), eq); | 3132 __ rotrdi(r5, r5, 1); // r5 = 0x80000000_00000000 |
| 3133 __ cmp(r4, r5); |
| 3134 #else |
| 3135 __ lwz(r5, FieldMemOperand(r3, HeapNumber::kExponentOffset)); |
| 3136 __ lwz(r4, FieldMemOperand(r3, HeapNumber::kMantissaOffset)); |
| 3137 Label skip; |
| 3138 __ lis(r0, Operand(SIGN_EXT_IMM16(0x8000))); |
| 3139 __ cmp(r5, r0); |
| 3140 __ bne(&skip); |
| 3141 __ cmpi(r4, Operand::Zero()); |
| 3142 __ bind(&skip); |
| 3143 #endif |
3140 | 3144 |
3141 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3145 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3142 Split(eq, if_true, if_false, fall_through); | 3146 Split(eq, if_true, if_false, fall_through); |
3143 | 3147 |
3144 context()->Plug(if_true, if_false); | 3148 context()->Plug(if_true, if_false); |
3145 } | 3149 } |
3146 | 3150 |
3147 | 3151 |
3148 void FullCodeGenerator::EmitIsArray(CallRuntime* expr) { | 3152 void FullCodeGenerator::EmitIsArray(CallRuntime* expr) { |
3149 ZoneList<Expression*>* args = expr->arguments(); | 3153 ZoneList<Expression*>* args = expr->arguments(); |
3150 DCHECK(args->length() == 1); | 3154 DCHECK(args->length() == 1); |
3151 | 3155 |
3152 VisitForAccumulatorValue(args->at(0)); | 3156 VisitForAccumulatorValue(args->at(0)); |
3153 | 3157 |
3154 Label materialize_true, materialize_false; | 3158 Label materialize_true, materialize_false; |
3155 Label* if_true = NULL; | 3159 Label* if_true = NULL; |
3156 Label* if_false = NULL; | 3160 Label* if_false = NULL; |
3157 Label* fall_through = NULL; | 3161 Label* fall_through = NULL; |
3158 context()->PrepareTest(&materialize_true, &materialize_false, | 3162 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
3159 &if_true, &if_false, &fall_through); | 3163 &if_false, &fall_through); |
3160 | 3164 |
3161 __ JumpIfSmi(r0, if_false); | 3165 __ JumpIfSmi(r3, if_false); |
3162 __ CompareObjectType(r0, r1, r1, JS_ARRAY_TYPE); | 3166 __ CompareObjectType(r3, r4, r4, JS_ARRAY_TYPE); |
3163 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3167 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3164 Split(eq, if_true, if_false, fall_through); | 3168 Split(eq, if_true, if_false, fall_through); |
3165 | 3169 |
3166 context()->Plug(if_true, if_false); | 3170 context()->Plug(if_true, if_false); |
3167 } | 3171 } |
3168 | 3172 |
3169 | 3173 |
3170 void FullCodeGenerator::EmitIsRegExp(CallRuntime* expr) { | 3174 void FullCodeGenerator::EmitIsRegExp(CallRuntime* expr) { |
3171 ZoneList<Expression*>* args = expr->arguments(); | 3175 ZoneList<Expression*>* args = expr->arguments(); |
3172 DCHECK(args->length() == 1); | 3176 DCHECK(args->length() == 1); |
3173 | 3177 |
3174 VisitForAccumulatorValue(args->at(0)); | 3178 VisitForAccumulatorValue(args->at(0)); |
3175 | 3179 |
3176 Label materialize_true, materialize_false; | 3180 Label materialize_true, materialize_false; |
3177 Label* if_true = NULL; | 3181 Label* if_true = NULL; |
3178 Label* if_false = NULL; | 3182 Label* if_false = NULL; |
3179 Label* fall_through = NULL; | 3183 Label* fall_through = NULL; |
3180 context()->PrepareTest(&materialize_true, &materialize_false, | 3184 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
3181 &if_true, &if_false, &fall_through); | 3185 &if_false, &fall_through); |
3182 | 3186 |
3183 __ JumpIfSmi(r0, if_false); | 3187 __ JumpIfSmi(r3, if_false); |
3184 __ CompareObjectType(r0, r1, r1, JS_REGEXP_TYPE); | 3188 __ CompareObjectType(r3, r4, r4, JS_REGEXP_TYPE); |
3185 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3189 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3186 Split(eq, if_true, if_false, fall_through); | 3190 Split(eq, if_true, if_false, fall_through); |
3187 | 3191 |
3188 context()->Plug(if_true, if_false); | 3192 context()->Plug(if_true, if_false); |
3189 } | 3193 } |
3190 | 3194 |
3191 | 3195 |
3192 | |
3193 void FullCodeGenerator::EmitIsConstructCall(CallRuntime* expr) { | 3196 void FullCodeGenerator::EmitIsConstructCall(CallRuntime* expr) { |
3194 DCHECK(expr->arguments()->length() == 0); | 3197 DCHECK(expr->arguments()->length() == 0); |
3195 | 3198 |
3196 Label materialize_true, materialize_false; | 3199 Label materialize_true, materialize_false; |
3197 Label* if_true = NULL; | 3200 Label* if_true = NULL; |
3198 Label* if_false = NULL; | 3201 Label* if_false = NULL; |
3199 Label* fall_through = NULL; | 3202 Label* fall_through = NULL; |
3200 context()->PrepareTest(&materialize_true, &materialize_false, | 3203 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
3201 &if_true, &if_false, &fall_through); | 3204 &if_false, &fall_through); |
3202 | 3205 |
3203 // Get the frame pointer for the calling frame. | 3206 // Get the frame pointer for the calling frame. |
3204 __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 3207 __ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
3205 | 3208 |
3206 // Skip the arguments adaptor frame if it exists. | 3209 // Skip the arguments adaptor frame if it exists. |
3207 __ ldr(r1, MemOperand(r2, StandardFrameConstants::kContextOffset)); | 3210 Label check_frame_marker; |
3208 __ cmp(r1, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 3211 __ LoadP(r4, MemOperand(r5, StandardFrameConstants::kContextOffset)); |
3209 __ ldr(r2, MemOperand(r2, StandardFrameConstants::kCallerFPOffset), eq); | 3212 __ CmpSmiLiteral(r4, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 3213 __ bne(&check_frame_marker); |
| 3214 __ LoadP(r5, MemOperand(r5, StandardFrameConstants::kCallerFPOffset)); |
3210 | 3215 |
3211 // Check the marker in the calling frame. | 3216 // Check the marker in the calling frame. |
3212 __ ldr(r1, MemOperand(r2, StandardFrameConstants::kMarkerOffset)); | 3217 __ bind(&check_frame_marker); |
3213 __ cmp(r1, Operand(Smi::FromInt(StackFrame::CONSTRUCT))); | 3218 __ LoadP(r4, MemOperand(r5, StandardFrameConstants::kMarkerOffset)); |
| 3219 STATIC_ASSERT(StackFrame::CONSTRUCT < 0x4000); |
| 3220 __ CmpSmiLiteral(r4, Smi::FromInt(StackFrame::CONSTRUCT), r0); |
3214 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3221 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3215 Split(eq, if_true, if_false, fall_through); | 3222 Split(eq, if_true, if_false, fall_through); |
3216 | 3223 |
3217 context()->Plug(if_true, if_false); | 3224 context()->Plug(if_true, if_false); |
3218 } | 3225 } |
3219 | 3226 |
3220 | 3227 |
3221 void FullCodeGenerator::EmitObjectEquals(CallRuntime* expr) { | 3228 void FullCodeGenerator::EmitObjectEquals(CallRuntime* expr) { |
3222 ZoneList<Expression*>* args = expr->arguments(); | 3229 ZoneList<Expression*>* args = expr->arguments(); |
3223 DCHECK(args->length() == 2); | 3230 DCHECK(args->length() == 2); |
3224 | 3231 |
3225 // Load the two objects into registers and perform the comparison. | 3232 // Load the two objects into registers and perform the comparison. |
3226 VisitForStackValue(args->at(0)); | 3233 VisitForStackValue(args->at(0)); |
3227 VisitForAccumulatorValue(args->at(1)); | 3234 VisitForAccumulatorValue(args->at(1)); |
3228 | 3235 |
3229 Label materialize_true, materialize_false; | 3236 Label materialize_true, materialize_false; |
3230 Label* if_true = NULL; | 3237 Label* if_true = NULL; |
3231 Label* if_false = NULL; | 3238 Label* if_false = NULL; |
3232 Label* fall_through = NULL; | 3239 Label* fall_through = NULL; |
3233 context()->PrepareTest(&materialize_true, &materialize_false, | 3240 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
3234 &if_true, &if_false, &fall_through); | 3241 &if_false, &fall_through); |
3235 | 3242 |
3236 __ pop(r1); | 3243 __ pop(r4); |
3237 __ cmp(r0, r1); | 3244 __ cmp(r3, r4); |
3238 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3245 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3239 Split(eq, if_true, if_false, fall_through); | 3246 Split(eq, if_true, if_false, fall_through); |
3240 | 3247 |
3241 context()->Plug(if_true, if_false); | 3248 context()->Plug(if_true, if_false); |
3242 } | 3249 } |
3243 | 3250 |
3244 | 3251 |
3245 void FullCodeGenerator::EmitArguments(CallRuntime* expr) { | 3252 void FullCodeGenerator::EmitArguments(CallRuntime* expr) { |
3246 ZoneList<Expression*>* args = expr->arguments(); | 3253 ZoneList<Expression*>* args = expr->arguments(); |
3247 DCHECK(args->length() == 1); | 3254 DCHECK(args->length() == 1); |
3248 | 3255 |
3249 // ArgumentsAccessStub expects the key in edx and the formal | 3256 // ArgumentsAccessStub expects the key in edx and the formal |
3250 // parameter count in r0. | 3257 // parameter count in r3. |
3251 VisitForAccumulatorValue(args->at(0)); | 3258 VisitForAccumulatorValue(args->at(0)); |
3252 __ mov(r1, r0); | 3259 __ mr(r4, r3); |
3253 __ mov(r0, Operand(Smi::FromInt(info_->scope()->num_parameters()))); | 3260 __ LoadSmiLiteral(r3, Smi::FromInt(info_->scope()->num_parameters())); |
3254 ArgumentsAccessStub stub(isolate(), ArgumentsAccessStub::READ_ELEMENT); | 3261 ArgumentsAccessStub stub(isolate(), ArgumentsAccessStub::READ_ELEMENT); |
3255 __ CallStub(&stub); | 3262 __ CallStub(&stub); |
3256 context()->Plug(r0); | 3263 context()->Plug(r3); |
3257 } | 3264 } |
3258 | 3265 |
3259 | 3266 |
3260 void FullCodeGenerator::EmitArgumentsLength(CallRuntime* expr) { | 3267 void FullCodeGenerator::EmitArgumentsLength(CallRuntime* expr) { |
3261 DCHECK(expr->arguments()->length() == 0); | 3268 DCHECK(expr->arguments()->length() == 0); |
3262 | 3269 Label exit; |
3263 // Get the number of formal parameters. | 3270 // Get the number of formal parameters. |
3264 __ mov(r0, Operand(Smi::FromInt(info_->scope()->num_parameters()))); | 3271 __ LoadSmiLiteral(r3, Smi::FromInt(info_->scope()->num_parameters())); |
3265 | 3272 |
3266 // Check if the calling frame is an arguments adaptor frame. | 3273 // Check if the calling frame is an arguments adaptor frame. |
3267 __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 3274 __ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
3268 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); | 3275 __ LoadP(r6, MemOperand(r5, StandardFrameConstants::kContextOffset)); |
3269 __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 3276 __ CmpSmiLiteral(r6, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 3277 __ bne(&exit); |
3270 | 3278 |
3271 // Arguments adaptor case: Read the arguments length from the | 3279 // Arguments adaptor case: Read the arguments length from the |
3272 // adaptor frame. | 3280 // adaptor frame. |
3273 __ ldr(r0, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset), eq); | 3281 __ LoadP(r3, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
3274 | 3282 |
3275 context()->Plug(r0); | 3283 __ bind(&exit); |
| 3284 context()->Plug(r3); |
3276 } | 3285 } |
3277 | 3286 |
3278 | 3287 |
3279 void FullCodeGenerator::EmitClassOf(CallRuntime* expr) { | 3288 void FullCodeGenerator::EmitClassOf(CallRuntime* expr) { |
3280 ZoneList<Expression*>* args = expr->arguments(); | 3289 ZoneList<Expression*>* args = expr->arguments(); |
3281 DCHECK(args->length() == 1); | 3290 DCHECK(args->length() == 1); |
3282 Label done, null, function, non_function_constructor; | 3291 Label done, null, function, non_function_constructor; |
3283 | 3292 |
3284 VisitForAccumulatorValue(args->at(0)); | 3293 VisitForAccumulatorValue(args->at(0)); |
3285 | 3294 |
3286 // If the object is a smi, we return null. | 3295 // If the object is a smi, we return null. |
3287 __ JumpIfSmi(r0, &null); | 3296 __ JumpIfSmi(r3, &null); |
3288 | 3297 |
3289 // Check that the object is a JS object but take special care of JS | 3298 // Check that the object is a JS object but take special care of JS |
3290 // functions to make sure they have 'Function' as their class. | 3299 // functions to make sure they have 'Function' as their class. |
3291 // Assume that there are only two callable types, and one of them is at | 3300 // Assume that there are only two callable types, and one of them is at |
3292 // either end of the type range for JS object types. Saves extra comparisons. | 3301 // either end of the type range for JS object types. Saves extra comparisons. |
3293 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | 3302 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
3294 __ CompareObjectType(r0, r0, r1, FIRST_SPEC_OBJECT_TYPE); | 3303 __ CompareObjectType(r3, r3, r4, FIRST_SPEC_OBJECT_TYPE); |
3295 // Map is now in r0. | 3304 // Map is now in r3. |
3296 __ b(lt, &null); | 3305 __ blt(&null); |
3297 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == | 3306 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
3298 FIRST_SPEC_OBJECT_TYPE + 1); | 3307 FIRST_SPEC_OBJECT_TYPE + 1); |
3299 __ b(eq, &function); | 3308 __ beq(&function); |
3300 | 3309 |
3301 __ cmp(r1, Operand(LAST_SPEC_OBJECT_TYPE)); | 3310 __ cmpi(r4, Operand(LAST_SPEC_OBJECT_TYPE)); |
3302 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | 3311 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_SPEC_OBJECT_TYPE - 1); |
3303 LAST_SPEC_OBJECT_TYPE - 1); | 3312 __ beq(&function); |
3304 __ b(eq, &function); | |
3305 // Assume that there is no larger type. | 3313 // Assume that there is no larger type. |
3306 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); | 3314 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); |
3307 | 3315 |
3308 // Check if the constructor in the map is a JS function. | 3316 // Check if the constructor in the map is a JS function. |
3309 __ ldr(r0, FieldMemOperand(r0, Map::kConstructorOffset)); | 3317 __ LoadP(r3, FieldMemOperand(r3, Map::kConstructorOffset)); |
3310 __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); | 3318 __ CompareObjectType(r3, r4, r4, JS_FUNCTION_TYPE); |
3311 __ b(ne, &non_function_constructor); | 3319 __ bne(&non_function_constructor); |
3312 | 3320 |
3313 // r0 now contains the constructor function. Grab the | 3321 // r3 now contains the constructor function. Grab the |
3314 // instance class name from there. | 3322 // instance class name from there. |
3315 __ ldr(r0, FieldMemOperand(r0, JSFunction::kSharedFunctionInfoOffset)); | 3323 __ LoadP(r3, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); |
3316 __ ldr(r0, FieldMemOperand(r0, SharedFunctionInfo::kInstanceClassNameOffset)); | 3324 __ LoadP(r3, |
| 3325 FieldMemOperand(r3, SharedFunctionInfo::kInstanceClassNameOffset)); |
3317 __ b(&done); | 3326 __ b(&done); |
3318 | 3327 |
3319 // Functions have class 'Function'. | 3328 // Functions have class 'Function'. |
3320 __ bind(&function); | 3329 __ bind(&function); |
3321 __ LoadRoot(r0, Heap::kFunction_stringRootIndex); | 3330 __ LoadRoot(r3, Heap::kFunction_stringRootIndex); |
3322 __ jmp(&done); | 3331 __ b(&done); |
3323 | 3332 |
3324 // Objects with a non-function constructor have class 'Object'. | 3333 // Objects with a non-function constructor have class 'Object'. |
3325 __ bind(&non_function_constructor); | 3334 __ bind(&non_function_constructor); |
3326 __ LoadRoot(r0, Heap::kObject_stringRootIndex); | 3335 __ LoadRoot(r3, Heap::kObject_stringRootIndex); |
3327 __ jmp(&done); | 3336 __ b(&done); |
3328 | 3337 |
3329 // Non-JS objects have class null. | 3338 // Non-JS objects have class null. |
3330 __ bind(&null); | 3339 __ bind(&null); |
3331 __ LoadRoot(r0, Heap::kNullValueRootIndex); | 3340 __ LoadRoot(r3, Heap::kNullValueRootIndex); |
3332 | 3341 |
3333 // All done. | 3342 // All done. |
3334 __ bind(&done); | 3343 __ bind(&done); |
3335 | 3344 |
3336 context()->Plug(r0); | 3345 context()->Plug(r3); |
3337 } | 3346 } |
3338 | 3347 |
3339 | 3348 |
3340 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { | 3349 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { |
3341 // Load the arguments on the stack and call the stub. | 3350 // Load the arguments on the stack and call the stub. |
3342 SubStringStub stub(isolate()); | 3351 SubStringStub stub(isolate()); |
3343 ZoneList<Expression*>* args = expr->arguments(); | 3352 ZoneList<Expression*>* args = expr->arguments(); |
3344 DCHECK(args->length() == 3); | 3353 DCHECK(args->length() == 3); |
3345 VisitForStackValue(args->at(0)); | 3354 VisitForStackValue(args->at(0)); |
3346 VisitForStackValue(args->at(1)); | 3355 VisitForStackValue(args->at(1)); |
3347 VisitForStackValue(args->at(2)); | 3356 VisitForStackValue(args->at(2)); |
3348 __ CallStub(&stub); | 3357 __ CallStub(&stub); |
3349 context()->Plug(r0); | 3358 context()->Plug(r3); |
3350 } | 3359 } |
3351 | 3360 |
3352 | 3361 |
3353 void FullCodeGenerator::EmitRegExpExec(CallRuntime* expr) { | 3362 void FullCodeGenerator::EmitRegExpExec(CallRuntime* expr) { |
3354 // Load the arguments on the stack and call the stub. | 3363 // Load the arguments on the stack and call the stub. |
3355 RegExpExecStub stub(isolate()); | 3364 RegExpExecStub stub(isolate()); |
3356 ZoneList<Expression*>* args = expr->arguments(); | 3365 ZoneList<Expression*>* args = expr->arguments(); |
3357 DCHECK(args->length() == 4); | 3366 DCHECK(args->length() == 4); |
3358 VisitForStackValue(args->at(0)); | 3367 VisitForStackValue(args->at(0)); |
3359 VisitForStackValue(args->at(1)); | 3368 VisitForStackValue(args->at(1)); |
3360 VisitForStackValue(args->at(2)); | 3369 VisitForStackValue(args->at(2)); |
3361 VisitForStackValue(args->at(3)); | 3370 VisitForStackValue(args->at(3)); |
3362 __ CallStub(&stub); | 3371 __ CallStub(&stub); |
3363 context()->Plug(r0); | 3372 context()->Plug(r3); |
3364 } | 3373 } |
3365 | 3374 |
3366 | 3375 |
3367 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { | 3376 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { |
3368 ZoneList<Expression*>* args = expr->arguments(); | 3377 ZoneList<Expression*>* args = expr->arguments(); |
3369 DCHECK(args->length() == 1); | 3378 DCHECK(args->length() == 1); |
3370 VisitForAccumulatorValue(args->at(0)); // Load the object. | 3379 VisitForAccumulatorValue(args->at(0)); // Load the object. |
3371 | 3380 |
3372 Label done; | 3381 Label done; |
3373 // If the object is a smi return the object. | 3382 // If the object is a smi return the object. |
3374 __ JumpIfSmi(r0, &done); | 3383 __ JumpIfSmi(r3, &done); |
3375 // If the object is not a value type, return the object. | 3384 // If the object is not a value type, return the object. |
3376 __ CompareObjectType(r0, r1, r1, JS_VALUE_TYPE); | 3385 __ CompareObjectType(r3, r4, r4, JS_VALUE_TYPE); |
3377 __ ldr(r0, FieldMemOperand(r0, JSValue::kValueOffset), eq); | 3386 __ bne(&done); |
| 3387 __ LoadP(r3, FieldMemOperand(r3, JSValue::kValueOffset)); |
3378 | 3388 |
3379 __ bind(&done); | 3389 __ bind(&done); |
3380 context()->Plug(r0); | 3390 context()->Plug(r3); |
3381 } | 3391 } |
3382 | 3392 |
3383 | 3393 |
3384 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { | 3394 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { |
3385 ZoneList<Expression*>* args = expr->arguments(); | 3395 ZoneList<Expression*>* args = expr->arguments(); |
3386 DCHECK(args->length() == 2); | 3396 DCHECK(args->length() == 2); |
3387 DCHECK_NE(NULL, args->at(1)->AsLiteral()); | 3397 DCHECK_NE(NULL, args->at(1)->AsLiteral()); |
3388 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->value())); | 3398 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->value())); |
3389 | 3399 |
3390 VisitForAccumulatorValue(args->at(0)); // Load the object. | 3400 VisitForAccumulatorValue(args->at(0)); // Load the object. |
3391 | 3401 |
3392 Label runtime, done, not_date_object; | 3402 Label runtime, done, not_date_object; |
3393 Register object = r0; | 3403 Register object = r3; |
3394 Register result = r0; | 3404 Register result = r3; |
3395 Register scratch0 = r9; | 3405 Register scratch0 = r11; |
3396 Register scratch1 = r1; | 3406 Register scratch1 = r4; |
3397 | 3407 |
3398 __ JumpIfSmi(object, ¬_date_object); | 3408 __ JumpIfSmi(object, ¬_date_object); |
3399 __ CompareObjectType(object, scratch1, scratch1, JS_DATE_TYPE); | 3409 __ CompareObjectType(object, scratch1, scratch1, JS_DATE_TYPE); |
3400 __ b(ne, ¬_date_object); | 3410 __ bne(¬_date_object); |
3401 | 3411 |
3402 if (index->value() == 0) { | 3412 if (index->value() == 0) { |
3403 __ ldr(result, FieldMemOperand(object, JSDate::kValueOffset)); | 3413 __ LoadP(result, FieldMemOperand(object, JSDate::kValueOffset)); |
3404 __ jmp(&done); | 3414 __ b(&done); |
3405 } else { | 3415 } else { |
3406 if (index->value() < JSDate::kFirstUncachedField) { | 3416 if (index->value() < JSDate::kFirstUncachedField) { |
3407 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); | 3417 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); |
3408 __ mov(scratch1, Operand(stamp)); | 3418 __ mov(scratch1, Operand(stamp)); |
3409 __ ldr(scratch1, MemOperand(scratch1)); | 3419 __ LoadP(scratch1, MemOperand(scratch1)); |
3410 __ ldr(scratch0, FieldMemOperand(object, JSDate::kCacheStampOffset)); | 3420 __ LoadP(scratch0, FieldMemOperand(object, JSDate::kCacheStampOffset)); |
3411 __ cmp(scratch1, scratch0); | 3421 __ cmp(scratch1, scratch0); |
3412 __ b(ne, &runtime); | 3422 __ bne(&runtime); |
3413 __ ldr(result, FieldMemOperand(object, JSDate::kValueOffset + | 3423 __ LoadP(result, |
3414 kPointerSize * index->value())); | 3424 FieldMemOperand(object, JSDate::kValueOffset + |
3415 __ jmp(&done); | 3425 kPointerSize * index->value()), |
| 3426 scratch0); |
| 3427 __ b(&done); |
3416 } | 3428 } |
3417 __ bind(&runtime); | 3429 __ bind(&runtime); |
3418 __ PrepareCallCFunction(2, scratch1); | 3430 __ PrepareCallCFunction(2, scratch1); |
3419 __ mov(r1, Operand(index)); | 3431 __ LoadSmiLiteral(r4, index); |
3420 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); | 3432 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); |
3421 __ jmp(&done); | 3433 __ b(&done); |
3422 } | 3434 } |
3423 | 3435 |
3424 __ bind(¬_date_object); | 3436 __ bind(¬_date_object); |
3425 __ CallRuntime(Runtime::kThrowNotDateError, 0); | 3437 __ CallRuntime(Runtime::kThrowNotDateError, 0); |
3426 __ bind(&done); | 3438 __ bind(&done); |
3427 context()->Plug(r0); | 3439 context()->Plug(r3); |
3428 } | 3440 } |
3429 | 3441 |
3430 | 3442 |
3431 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { | 3443 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { |
3432 ZoneList<Expression*>* args = expr->arguments(); | 3444 ZoneList<Expression*>* args = expr->arguments(); |
3433 DCHECK_EQ(3, args->length()); | 3445 DCHECK_EQ(3, args->length()); |
3434 | 3446 |
3435 Register string = r0; | 3447 Register string = r3; |
3436 Register index = r1; | 3448 Register index = r4; |
3437 Register value = r2; | 3449 Register value = r5; |
3438 | 3450 |
3439 VisitForStackValue(args->at(1)); // index | 3451 VisitForStackValue(args->at(1)); // index |
3440 VisitForStackValue(args->at(2)); // value | 3452 VisitForStackValue(args->at(2)); // value |
3441 VisitForAccumulatorValue(args->at(0)); // string | 3453 VisitForAccumulatorValue(args->at(0)); // string |
3442 __ Pop(index, value); | 3454 __ Pop(index, value); |
3443 | 3455 |
3444 if (FLAG_debug_code) { | 3456 if (FLAG_debug_code) { |
3445 __ SmiTst(value); | 3457 __ TestIfSmi(value, r0); |
3446 __ Check(eq, kNonSmiValue); | 3458 __ Check(eq, kNonSmiValue, cr0); |
3447 __ SmiTst(index); | 3459 __ TestIfSmi(index, r0); |
3448 __ Check(eq, kNonSmiIndex); | 3460 __ Check(eq, kNonSmiIndex, cr0); |
3449 __ SmiUntag(index, index); | 3461 __ SmiUntag(index, index); |
3450 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; | 3462 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; |
3451 __ EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type); | 3463 __ EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type); |
3452 __ SmiTag(index, index); | 3464 __ SmiTag(index, index); |
3453 } | 3465 } |
3454 | 3466 |
3455 __ SmiUntag(value, value); | 3467 __ SmiUntag(value); |
3456 __ add(ip, | 3468 __ addi(ip, string, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
3457 string, | 3469 __ SmiToByteArrayOffset(r0, index); |
3458 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 3470 __ stbx(value, MemOperand(ip, r0)); |
3459 __ strb(value, MemOperand(ip, index, LSR, kSmiTagSize)); | |
3460 context()->Plug(string); | 3471 context()->Plug(string); |
3461 } | 3472 } |
3462 | 3473 |
3463 | 3474 |
3464 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { | 3475 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { |
3465 ZoneList<Expression*>* args = expr->arguments(); | 3476 ZoneList<Expression*>* args = expr->arguments(); |
3466 DCHECK_EQ(3, args->length()); | 3477 DCHECK_EQ(3, args->length()); |
3467 | 3478 |
3468 Register string = r0; | 3479 Register string = r3; |
3469 Register index = r1; | 3480 Register index = r4; |
3470 Register value = r2; | 3481 Register value = r5; |
3471 | 3482 |
3472 VisitForStackValue(args->at(1)); // index | 3483 VisitForStackValue(args->at(1)); // index |
3473 VisitForStackValue(args->at(2)); // value | 3484 VisitForStackValue(args->at(2)); // value |
3474 VisitForAccumulatorValue(args->at(0)); // string | 3485 VisitForAccumulatorValue(args->at(0)); // string |
3475 __ Pop(index, value); | 3486 __ Pop(index, value); |
3476 | 3487 |
3477 if (FLAG_debug_code) { | 3488 if (FLAG_debug_code) { |
3478 __ SmiTst(value); | 3489 __ TestIfSmi(value, r0); |
3479 __ Check(eq, kNonSmiValue); | 3490 __ Check(eq, kNonSmiValue, cr0); |
3480 __ SmiTst(index); | 3491 __ TestIfSmi(index, r0); |
3481 __ Check(eq, kNonSmiIndex); | 3492 __ Check(eq, kNonSmiIndex, cr0); |
3482 __ SmiUntag(index, index); | 3493 __ SmiUntag(index, index); |
3483 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; | 3494 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; |
3484 __ EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); | 3495 __ EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); |
3485 __ SmiTag(index, index); | 3496 __ SmiTag(index, index); |
3486 } | 3497 } |
3487 | 3498 |
3488 __ SmiUntag(value, value); | 3499 __ SmiUntag(value); |
3489 __ add(ip, | 3500 __ addi(ip, string, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
3490 string, | 3501 __ SmiToShortArrayOffset(r0, index); |
3491 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 3502 __ sthx(value, MemOperand(ip, r0)); |
3492 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | |
3493 __ strh(value, MemOperand(ip, index)); | |
3494 context()->Plug(string); | 3503 context()->Plug(string); |
3495 } | 3504 } |
3496 | 3505 |
3497 | 3506 |
3498 | |
3499 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 3507 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
3500 // Load the arguments on the stack and call the runtime function. | 3508 // Load the arguments on the stack and call the runtime function. |
3501 ZoneList<Expression*>* args = expr->arguments(); | 3509 ZoneList<Expression*>* args = expr->arguments(); |
3502 DCHECK(args->length() == 2); | 3510 DCHECK(args->length() == 2); |
3503 VisitForStackValue(args->at(0)); | 3511 VisitForStackValue(args->at(0)); |
3504 VisitForStackValue(args->at(1)); | 3512 VisitForStackValue(args->at(1)); |
3505 MathPowStub stub(isolate(), MathPowStub::ON_STACK); | 3513 MathPowStub stub(isolate(), MathPowStub::ON_STACK); |
3506 __ CallStub(&stub); | 3514 __ CallStub(&stub); |
3507 context()->Plug(r0); | 3515 context()->Plug(r3); |
3508 } | 3516 } |
3509 | 3517 |
3510 | 3518 |
3511 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { | 3519 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { |
3512 ZoneList<Expression*>* args = expr->arguments(); | 3520 ZoneList<Expression*>* args = expr->arguments(); |
3513 DCHECK(args->length() == 2); | 3521 DCHECK(args->length() == 2); |
3514 VisitForStackValue(args->at(0)); // Load the object. | 3522 VisitForStackValue(args->at(0)); // Load the object. |
3515 VisitForAccumulatorValue(args->at(1)); // Load the value. | 3523 VisitForAccumulatorValue(args->at(1)); // Load the value. |
3516 __ pop(r1); // r0 = value. r1 = object. | 3524 __ pop(r4); // r3 = value. r4 = object. |
3517 | 3525 |
3518 Label done; | 3526 Label done; |
3519 // If the object is a smi, return the value. | 3527 // If the object is a smi, return the value. |
3520 __ JumpIfSmi(r1, &done); | 3528 __ JumpIfSmi(r4, &done); |
3521 | 3529 |
3522 // If the object is not a value type, return the value. | 3530 // If the object is not a value type, return the value. |
3523 __ CompareObjectType(r1, r2, r2, JS_VALUE_TYPE); | 3531 __ CompareObjectType(r4, r5, r5, JS_VALUE_TYPE); |
3524 __ b(ne, &done); | 3532 __ bne(&done); |
3525 | 3533 |
3526 // Store the value. | 3534 // Store the value. |
3527 __ str(r0, FieldMemOperand(r1, JSValue::kValueOffset)); | 3535 __ StoreP(r3, FieldMemOperand(r4, JSValue::kValueOffset), r0); |
3528 // Update the write barrier. Save the value as it will be | 3536 // Update the write barrier. Save the value as it will be |
3529 // overwritten by the write barrier code and is needed afterward. | 3537 // overwritten by the write barrier code and is needed afterward. |
3530 __ mov(r2, r0); | 3538 __ mr(r5, r3); |
3531 __ RecordWriteField( | 3539 __ RecordWriteField(r4, JSValue::kValueOffset, r5, r6, kLRHasBeenSaved, |
3532 r1, JSValue::kValueOffset, r2, r3, kLRHasBeenSaved, kDontSaveFPRegs); | 3540 kDontSaveFPRegs); |
3533 | 3541 |
3534 __ bind(&done); | 3542 __ bind(&done); |
3535 context()->Plug(r0); | 3543 context()->Plug(r3); |
3536 } | 3544 } |
3537 | 3545 |
3538 | 3546 |
3539 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { | 3547 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { |
3540 ZoneList<Expression*>* args = expr->arguments(); | 3548 ZoneList<Expression*>* args = expr->arguments(); |
3541 DCHECK_EQ(args->length(), 1); | 3549 DCHECK_EQ(args->length(), 1); |
3542 // Load the argument into r0 and call the stub. | 3550 // Load the argument into r3 and call the stub. |
3543 VisitForAccumulatorValue(args->at(0)); | 3551 VisitForAccumulatorValue(args->at(0)); |
3544 | 3552 |
3545 NumberToStringStub stub(isolate()); | 3553 NumberToStringStub stub(isolate()); |
3546 __ CallStub(&stub); | 3554 __ CallStub(&stub); |
3547 context()->Plug(r0); | 3555 context()->Plug(r3); |
3548 } | 3556 } |
3549 | 3557 |
3550 | 3558 |
3551 void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) { | 3559 void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) { |
3552 ZoneList<Expression*>* args = expr->arguments(); | 3560 ZoneList<Expression*>* args = expr->arguments(); |
3553 DCHECK(args->length() == 1); | 3561 DCHECK(args->length() == 1); |
3554 VisitForAccumulatorValue(args->at(0)); | 3562 VisitForAccumulatorValue(args->at(0)); |
3555 | 3563 |
3556 Label done; | 3564 Label done; |
3557 StringCharFromCodeGenerator generator(r0, r1); | 3565 StringCharFromCodeGenerator generator(r3, r4); |
3558 generator.GenerateFast(masm_); | 3566 generator.GenerateFast(masm_); |
3559 __ jmp(&done); | 3567 __ b(&done); |
3560 | 3568 |
3561 NopRuntimeCallHelper call_helper; | 3569 NopRuntimeCallHelper call_helper; |
3562 generator.GenerateSlow(masm_, call_helper); | 3570 generator.GenerateSlow(masm_, call_helper); |
3563 | 3571 |
3564 __ bind(&done); | 3572 __ bind(&done); |
3565 context()->Plug(r1); | 3573 context()->Plug(r4); |
3566 } | 3574 } |
3567 | 3575 |
3568 | 3576 |
3569 void FullCodeGenerator::EmitStringCharCodeAt(CallRuntime* expr) { | 3577 void FullCodeGenerator::EmitStringCharCodeAt(CallRuntime* expr) { |
3570 ZoneList<Expression*>* args = expr->arguments(); | 3578 ZoneList<Expression*>* args = expr->arguments(); |
3571 DCHECK(args->length() == 2); | 3579 DCHECK(args->length() == 2); |
3572 VisitForStackValue(args->at(0)); | 3580 VisitForStackValue(args->at(0)); |
3573 VisitForAccumulatorValue(args->at(1)); | 3581 VisitForAccumulatorValue(args->at(1)); |
3574 | 3582 |
3575 Register object = r1; | 3583 Register object = r4; |
3576 Register index = r0; | 3584 Register index = r3; |
3577 Register result = r3; | 3585 Register result = r6; |
3578 | 3586 |
3579 __ pop(object); | 3587 __ pop(object); |
3580 | 3588 |
3581 Label need_conversion; | 3589 Label need_conversion; |
3582 Label index_out_of_range; | 3590 Label index_out_of_range; |
3583 Label done; | 3591 Label done; |
3584 StringCharCodeAtGenerator generator(object, | 3592 StringCharCodeAtGenerator generator(object, index, result, &need_conversion, |
3585 index, | 3593 &need_conversion, &index_out_of_range, |
3586 result, | |
3587 &need_conversion, | |
3588 &need_conversion, | |
3589 &index_out_of_range, | |
3590 STRING_INDEX_IS_NUMBER); | 3594 STRING_INDEX_IS_NUMBER); |
3591 generator.GenerateFast(masm_); | 3595 generator.GenerateFast(masm_); |
3592 __ jmp(&done); | 3596 __ b(&done); |
3593 | 3597 |
3594 __ bind(&index_out_of_range); | 3598 __ bind(&index_out_of_range); |
3595 // When the index is out of range, the spec requires us to return | 3599 // When the index is out of range, the spec requires us to return |
3596 // NaN. | 3600 // NaN. |
3597 __ LoadRoot(result, Heap::kNanValueRootIndex); | 3601 __ LoadRoot(result, Heap::kNanValueRootIndex); |
3598 __ jmp(&done); | 3602 __ b(&done); |
3599 | 3603 |
3600 __ bind(&need_conversion); | 3604 __ bind(&need_conversion); |
3601 // Load the undefined value into the result register, which will | 3605 // Load the undefined value into the result register, which will |
3602 // trigger conversion. | 3606 // trigger conversion. |
3603 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); | 3607 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); |
3604 __ jmp(&done); | 3608 __ b(&done); |
3605 | 3609 |
3606 NopRuntimeCallHelper call_helper; | 3610 NopRuntimeCallHelper call_helper; |
3607 generator.GenerateSlow(masm_, call_helper); | 3611 generator.GenerateSlow(masm_, call_helper); |
3608 | 3612 |
3609 __ bind(&done); | 3613 __ bind(&done); |
3610 context()->Plug(result); | 3614 context()->Plug(result); |
3611 } | 3615 } |
3612 | 3616 |
3613 | 3617 |
3614 void FullCodeGenerator::EmitStringCharAt(CallRuntime* expr) { | 3618 void FullCodeGenerator::EmitStringCharAt(CallRuntime* expr) { |
3615 ZoneList<Expression*>* args = expr->arguments(); | 3619 ZoneList<Expression*>* args = expr->arguments(); |
3616 DCHECK(args->length() == 2); | 3620 DCHECK(args->length() == 2); |
3617 VisitForStackValue(args->at(0)); | 3621 VisitForStackValue(args->at(0)); |
3618 VisitForAccumulatorValue(args->at(1)); | 3622 VisitForAccumulatorValue(args->at(1)); |
3619 | 3623 |
3620 Register object = r1; | 3624 Register object = r4; |
3621 Register index = r0; | 3625 Register index = r3; |
3622 Register scratch = r3; | 3626 Register scratch = r6; |
3623 Register result = r0; | 3627 Register result = r3; |
3624 | 3628 |
3625 __ pop(object); | 3629 __ pop(object); |
3626 | 3630 |
3627 Label need_conversion; | 3631 Label need_conversion; |
3628 Label index_out_of_range; | 3632 Label index_out_of_range; |
3629 Label done; | 3633 Label done; |
3630 StringCharAtGenerator generator(object, | 3634 StringCharAtGenerator generator(object, index, scratch, result, |
3631 index, | 3635 &need_conversion, &need_conversion, |
3632 scratch, | 3636 &index_out_of_range, STRING_INDEX_IS_NUMBER); |
3633 result, | |
3634 &need_conversion, | |
3635 &need_conversion, | |
3636 &index_out_of_range, | |
3637 STRING_INDEX_IS_NUMBER); | |
3638 generator.GenerateFast(masm_); | 3637 generator.GenerateFast(masm_); |
3639 __ jmp(&done); | 3638 __ b(&done); |
3640 | 3639 |
3641 __ bind(&index_out_of_range); | 3640 __ bind(&index_out_of_range); |
3642 // When the index is out of range, the spec requires us to return | 3641 // When the index is out of range, the spec requires us to return |
3643 // the empty string. | 3642 // the empty string. |
3644 __ LoadRoot(result, Heap::kempty_stringRootIndex); | 3643 __ LoadRoot(result, Heap::kempty_stringRootIndex); |
3645 __ jmp(&done); | 3644 __ b(&done); |
3646 | 3645 |
3647 __ bind(&need_conversion); | 3646 __ bind(&need_conversion); |
3648 // Move smi zero into the result register, which will trigger | 3647 // Move smi zero into the result register, which will trigger |
3649 // conversion. | 3648 // conversion. |
3650 __ mov(result, Operand(Smi::FromInt(0))); | 3649 __ LoadSmiLiteral(result, Smi::FromInt(0)); |
3651 __ jmp(&done); | 3650 __ b(&done); |
3652 | 3651 |
3653 NopRuntimeCallHelper call_helper; | 3652 NopRuntimeCallHelper call_helper; |
3654 generator.GenerateSlow(masm_, call_helper); | 3653 generator.GenerateSlow(masm_, call_helper); |
3655 | 3654 |
3656 __ bind(&done); | 3655 __ bind(&done); |
3657 context()->Plug(result); | 3656 context()->Plug(result); |
3658 } | 3657 } |
3659 | 3658 |
3660 | 3659 |
3661 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { | 3660 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { |
3662 ZoneList<Expression*>* args = expr->arguments(); | 3661 ZoneList<Expression*>* args = expr->arguments(); |
3663 DCHECK_EQ(2, args->length()); | 3662 DCHECK_EQ(2, args->length()); |
3664 VisitForStackValue(args->at(0)); | 3663 VisitForStackValue(args->at(0)); |
3665 VisitForAccumulatorValue(args->at(1)); | 3664 VisitForAccumulatorValue(args->at(1)); |
3666 | 3665 |
3667 __ pop(r1); | 3666 __ pop(r4); |
3668 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED); | 3667 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED); |
3669 __ CallStub(&stub); | 3668 __ CallStub(&stub); |
3670 context()->Plug(r0); | 3669 context()->Plug(r3); |
3671 } | 3670 } |
3672 | 3671 |
3673 | 3672 |
3674 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { | 3673 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { |
3675 ZoneList<Expression*>* args = expr->arguments(); | 3674 ZoneList<Expression*>* args = expr->arguments(); |
3676 DCHECK_EQ(2, args->length()); | 3675 DCHECK_EQ(2, args->length()); |
3677 VisitForStackValue(args->at(0)); | 3676 VisitForStackValue(args->at(0)); |
3678 VisitForStackValue(args->at(1)); | 3677 VisitForStackValue(args->at(1)); |
3679 | 3678 |
3680 StringCompareStub stub(isolate()); | 3679 StringCompareStub stub(isolate()); |
3681 __ CallStub(&stub); | 3680 __ CallStub(&stub); |
3682 context()->Plug(r0); | 3681 context()->Plug(r3); |
3683 } | 3682 } |
3684 | 3683 |
3685 | 3684 |
3686 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { | 3685 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { |
3687 ZoneList<Expression*>* args = expr->arguments(); | 3686 ZoneList<Expression*>* args = expr->arguments(); |
3688 DCHECK(args->length() >= 2); | 3687 DCHECK(args->length() >= 2); |
3689 | 3688 |
3690 int arg_count = args->length() - 2; // 2 ~ receiver and function. | 3689 int arg_count = args->length() - 2; // 2 ~ receiver and function. |
3691 for (int i = 0; i < arg_count + 1; i++) { | 3690 for (int i = 0; i < arg_count + 1; i++) { |
3692 VisitForStackValue(args->at(i)); | 3691 VisitForStackValue(args->at(i)); |
3693 } | 3692 } |
3694 VisitForAccumulatorValue(args->last()); // Function. | 3693 VisitForAccumulatorValue(args->last()); // Function. |
3695 | 3694 |
3696 Label runtime, done; | 3695 Label runtime, done; |
3697 // Check for non-function argument (including proxy). | 3696 // Check for non-function argument (including proxy). |
3698 __ JumpIfSmi(r0, &runtime); | 3697 __ JumpIfSmi(r3, &runtime); |
3699 __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); | 3698 __ CompareObjectType(r3, r4, r4, JS_FUNCTION_TYPE); |
3700 __ b(ne, &runtime); | 3699 __ bne(&runtime); |
3701 | 3700 |
3702 // InvokeFunction requires the function in r1. Move it in there. | 3701 // InvokeFunction requires the function in r4. Move it in there. |
3703 __ mov(r1, result_register()); | 3702 __ mr(r4, result_register()); |
3704 ParameterCount count(arg_count); | 3703 ParameterCount count(arg_count); |
3705 __ InvokeFunction(r1, count, CALL_FUNCTION, NullCallWrapper()); | 3704 __ InvokeFunction(r4, count, CALL_FUNCTION, NullCallWrapper()); |
3706 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 3705 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
3707 __ jmp(&done); | 3706 __ b(&done); |
3708 | 3707 |
3709 __ bind(&runtime); | 3708 __ bind(&runtime); |
3710 __ push(r0); | 3709 __ push(r3); |
3711 __ CallRuntime(Runtime::kCall, args->length()); | 3710 __ CallRuntime(Runtime::kCall, args->length()); |
3712 __ bind(&done); | 3711 __ bind(&done); |
3713 | 3712 |
3714 context()->Plug(r0); | 3713 context()->Plug(r3); |
3715 } | 3714 } |
3716 | 3715 |
3717 | 3716 |
3718 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { | 3717 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { |
3719 RegExpConstructResultStub stub(isolate()); | 3718 RegExpConstructResultStub stub(isolate()); |
3720 ZoneList<Expression*>* args = expr->arguments(); | 3719 ZoneList<Expression*>* args = expr->arguments(); |
3721 DCHECK(args->length() == 3); | 3720 DCHECK(args->length() == 3); |
3722 VisitForStackValue(args->at(0)); | 3721 VisitForStackValue(args->at(0)); |
3723 VisitForStackValue(args->at(1)); | 3722 VisitForStackValue(args->at(1)); |
3724 VisitForAccumulatorValue(args->at(2)); | 3723 VisitForAccumulatorValue(args->at(2)); |
3725 __ pop(r1); | 3724 __ Pop(r5, r4); |
3726 __ pop(r2); | |
3727 __ CallStub(&stub); | 3725 __ CallStub(&stub); |
3728 context()->Plug(r0); | 3726 context()->Plug(r3); |
3729 } | 3727 } |
3730 | 3728 |
3731 | 3729 |
3732 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { | 3730 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { |
3733 ZoneList<Expression*>* args = expr->arguments(); | 3731 ZoneList<Expression*>* args = expr->arguments(); |
3734 DCHECK_EQ(2, args->length()); | 3732 DCHECK_EQ(2, args->length()); |
3735 DCHECK_NE(NULL, args->at(0)->AsLiteral()); | 3733 DCHECK_NE(NULL, args->at(0)->AsLiteral()); |
3736 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->value()))->value(); | 3734 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->value()))->value(); |
3737 | 3735 |
3738 Handle<FixedArray> jsfunction_result_caches( | 3736 Handle<FixedArray> jsfunction_result_caches( |
3739 isolate()->native_context()->jsfunction_result_caches()); | 3737 isolate()->native_context()->jsfunction_result_caches()); |
3740 if (jsfunction_result_caches->length() <= cache_id) { | 3738 if (jsfunction_result_caches->length() <= cache_id) { |
3741 __ Abort(kAttemptToUseUndefinedCache); | 3739 __ Abort(kAttemptToUseUndefinedCache); |
3742 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 3740 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
3743 context()->Plug(r0); | 3741 context()->Plug(r3); |
3744 return; | 3742 return; |
3745 } | 3743 } |
3746 | 3744 |
3747 VisitForAccumulatorValue(args->at(1)); | 3745 VisitForAccumulatorValue(args->at(1)); |
3748 | 3746 |
3749 Register key = r0; | 3747 Register key = r3; |
3750 Register cache = r1; | 3748 Register cache = r4; |
3751 __ ldr(cache, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); | 3749 __ LoadP(cache, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); |
3752 __ ldr(cache, FieldMemOperand(cache, GlobalObject::kNativeContextOffset)); | 3750 __ LoadP(cache, FieldMemOperand(cache, GlobalObject::kNativeContextOffset)); |
3753 __ ldr(cache, ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX)); | 3751 __ LoadP(cache, |
3754 __ ldr(cache, | 3752 ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX)); |
3755 FieldMemOperand(cache, FixedArray::OffsetOfElementAt(cache_id))); | 3753 __ LoadP(cache, |
3756 | 3754 FieldMemOperand(cache, FixedArray::OffsetOfElementAt(cache_id)), r0); |
3757 | 3755 |
3758 Label done, not_found; | 3756 Label done, not_found; |
3759 __ ldr(r2, FieldMemOperand(cache, JSFunctionResultCache::kFingerOffset)); | 3757 __ LoadP(r5, FieldMemOperand(cache, JSFunctionResultCache::kFingerOffset)); |
3760 // r2 now holds finger offset as a smi. | 3758 // r5 now holds finger offset as a smi. |
3761 __ add(r3, cache, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 3759 __ addi(r6, cache, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
3762 // r3 now points to the start of fixed array elements. | 3760 // r6 now points to the start of fixed array elements. |
3763 __ ldr(r2, MemOperand::PointerAddressFromSmiKey(r3, r2, PreIndex)); | 3761 __ SmiToPtrArrayOffset(r5, r5); |
3764 // Note side effect of PreIndex: r3 now points to the key of the pair. | 3762 __ LoadPUX(r5, MemOperand(r6, r5)); |
3765 __ cmp(key, r2); | 3763 // r6 now points to the key of the pair. |
3766 __ b(ne, ¬_found); | 3764 __ cmp(key, r5); |
| 3765 __ bne(¬_found); |
3767 | 3766 |
3768 __ ldr(r0, MemOperand(r3, kPointerSize)); | 3767 __ LoadP(r3, MemOperand(r6, kPointerSize)); |
3769 __ b(&done); | 3768 __ b(&done); |
3770 | 3769 |
3771 __ bind(¬_found); | 3770 __ bind(¬_found); |
3772 // Call runtime to perform the lookup. | 3771 // Call runtime to perform the lookup. |
3773 __ Push(cache, key); | 3772 __ Push(cache, key); |
3774 __ CallRuntime(Runtime::kGetFromCache, 2); | 3773 __ CallRuntime(Runtime::kGetFromCache, 2); |
3775 | 3774 |
3776 __ bind(&done); | 3775 __ bind(&done); |
3777 context()->Plug(r0); | 3776 context()->Plug(r3); |
3778 } | 3777 } |
3779 | 3778 |
3780 | 3779 |
3781 void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) { | 3780 void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) { |
3782 ZoneList<Expression*>* args = expr->arguments(); | 3781 ZoneList<Expression*>* args = expr->arguments(); |
3783 VisitForAccumulatorValue(args->at(0)); | 3782 VisitForAccumulatorValue(args->at(0)); |
3784 | 3783 |
3785 Label materialize_true, materialize_false; | 3784 Label materialize_true, materialize_false; |
3786 Label* if_true = NULL; | 3785 Label* if_true = NULL; |
3787 Label* if_false = NULL; | 3786 Label* if_false = NULL; |
3788 Label* fall_through = NULL; | 3787 Label* fall_through = NULL; |
3789 context()->PrepareTest(&materialize_true, &materialize_false, | 3788 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
3790 &if_true, &if_false, &fall_through); | 3789 &if_false, &fall_through); |
3791 | 3790 |
3792 __ ldr(r0, FieldMemOperand(r0, String::kHashFieldOffset)); | 3791 __ lwz(r3, FieldMemOperand(r3, String::kHashFieldOffset)); |
3793 __ tst(r0, Operand(String::kContainsCachedArrayIndexMask)); | 3792 // PPC - assume ip is free |
| 3793 __ mov(ip, Operand(String::kContainsCachedArrayIndexMask)); |
| 3794 __ and_(r0, r3, ip); |
| 3795 __ cmpi(r0, Operand::Zero()); |
3794 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3796 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3795 Split(eq, if_true, if_false, fall_through); | 3797 Split(eq, if_true, if_false, fall_through); |
3796 | 3798 |
3797 context()->Plug(if_true, if_false); | 3799 context()->Plug(if_true, if_false); |
3798 } | 3800 } |
3799 | 3801 |
3800 | 3802 |
3801 void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) { | 3803 void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) { |
3802 ZoneList<Expression*>* args = expr->arguments(); | 3804 ZoneList<Expression*>* args = expr->arguments(); |
3803 DCHECK(args->length() == 1); | 3805 DCHECK(args->length() == 1); |
3804 VisitForAccumulatorValue(args->at(0)); | 3806 VisitForAccumulatorValue(args->at(0)); |
3805 | 3807 |
3806 __ AssertString(r0); | 3808 __ AssertString(r3); |
3807 | 3809 |
3808 __ ldr(r0, FieldMemOperand(r0, String::kHashFieldOffset)); | 3810 __ lwz(r3, FieldMemOperand(r3, String::kHashFieldOffset)); |
3809 __ IndexFromHash(r0, r0); | 3811 __ IndexFromHash(r3, r3); |
3810 | 3812 |
3811 context()->Plug(r0); | 3813 context()->Plug(r3); |
3812 } | 3814 } |
3813 | 3815 |
3814 | 3816 |
3815 void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { | 3817 void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { |
3816 Label bailout, done, one_char_separator, long_separator, non_trivial_array, | 3818 Label bailout, done, one_char_separator, long_separator, non_trivial_array, |
3817 not_size_one_array, loop, empty_separator_loop, one_char_separator_loop, | 3819 not_size_one_array, loop, empty_separator_loop, one_char_separator_loop, |
3818 one_char_separator_loop_entry, long_separator_loop; | 3820 one_char_separator_loop_entry, long_separator_loop; |
3819 ZoneList<Expression*>* args = expr->arguments(); | 3821 ZoneList<Expression*>* args = expr->arguments(); |
3820 DCHECK(args->length() == 2); | 3822 DCHECK(args->length() == 2); |
3821 VisitForStackValue(args->at(1)); | 3823 VisitForStackValue(args->at(1)); |
3822 VisitForAccumulatorValue(args->at(0)); | 3824 VisitForAccumulatorValue(args->at(0)); |
3823 | 3825 |
3824 // All aliases of the same register have disjoint lifetimes. | 3826 // All aliases of the same register have disjoint lifetimes. |
3825 Register array = r0; | 3827 Register array = r3; |
3826 Register elements = no_reg; // Will be r0. | 3828 Register elements = no_reg; // Will be r3. |
3827 Register result = no_reg; // Will be r0. | 3829 Register result = no_reg; // Will be r3. |
3828 Register separator = r1; | 3830 Register separator = r4; |
3829 Register array_length = r2; | 3831 Register array_length = r5; |
3830 Register result_pos = no_reg; // Will be r2 | 3832 Register result_pos = no_reg; // Will be r5 |
3831 Register string_length = r3; | 3833 Register string_length = r6; |
3832 Register string = r4; | 3834 Register string = r7; |
3833 Register element = r5; | 3835 Register element = r8; |
3834 Register elements_end = r6; | 3836 Register elements_end = r9; |
3835 Register scratch = r9; | 3837 Register scratch1 = r10; |
| 3838 Register scratch2 = r11; |
3836 | 3839 |
3837 // Separator operand is on the stack. | 3840 // Separator operand is on the stack. |
3838 __ pop(separator); | 3841 __ pop(separator); |
3839 | 3842 |
3840 // Check that the array is a JSArray. | 3843 // Check that the array is a JSArray. |
3841 __ JumpIfSmi(array, &bailout); | 3844 __ JumpIfSmi(array, &bailout); |
3842 __ CompareObjectType(array, scratch, array_length, JS_ARRAY_TYPE); | 3845 __ CompareObjectType(array, scratch1, scratch2, JS_ARRAY_TYPE); |
3843 __ b(ne, &bailout); | 3846 __ bne(&bailout); |
3844 | 3847 |
3845 // Check that the array has fast elements. | 3848 // Check that the array has fast elements. |
3846 __ CheckFastElements(scratch, array_length, &bailout); | 3849 __ CheckFastElements(scratch1, scratch2, &bailout); |
3847 | 3850 |
3848 // If the array has length zero, return the empty string. | 3851 // If the array has length zero, return the empty string. |
3849 __ ldr(array_length, FieldMemOperand(array, JSArray::kLengthOffset)); | 3852 __ LoadP(array_length, FieldMemOperand(array, JSArray::kLengthOffset)); |
3850 __ SmiUntag(array_length, SetCC); | 3853 __ SmiUntag(array_length); |
3851 __ b(ne, &non_trivial_array); | 3854 __ cmpi(array_length, Operand::Zero()); |
3852 __ LoadRoot(r0, Heap::kempty_stringRootIndex); | 3855 __ bne(&non_trivial_array); |
| 3856 __ LoadRoot(r3, Heap::kempty_stringRootIndex); |
3853 __ b(&done); | 3857 __ b(&done); |
3854 | 3858 |
3855 __ bind(&non_trivial_array); | 3859 __ bind(&non_trivial_array); |
3856 | 3860 |
3857 // Get the FixedArray containing array's elements. | 3861 // Get the FixedArray containing array's elements. |
3858 elements = array; | 3862 elements = array; |
3859 __ ldr(elements, FieldMemOperand(array, JSArray::kElementsOffset)); | 3863 __ LoadP(elements, FieldMemOperand(array, JSArray::kElementsOffset)); |
3860 array = no_reg; // End of array's live range. | 3864 array = no_reg; // End of array's live range. |
3861 | 3865 |
3862 // Check that all array elements are sequential ASCII strings, and | 3866 // Check that all array elements are sequential ASCII strings, and |
3863 // accumulate the sum of their lengths, as a smi-encoded value. | 3867 // accumulate the sum of their lengths, as a smi-encoded value. |
3864 __ mov(string_length, Operand::Zero()); | 3868 __ li(string_length, Operand::Zero()); |
3865 __ add(element, | 3869 __ addi(element, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
3866 elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 3870 __ ShiftLeftImm(elements_end, array_length, Operand(kPointerSizeLog2)); |
3867 __ add(elements_end, element, Operand(array_length, LSL, kPointerSizeLog2)); | 3871 __ add(elements_end, element, elements_end); |
3868 // Loop condition: while (element < elements_end). | 3872 // Loop condition: while (element < elements_end). |
3869 // Live values in registers: | 3873 // Live values in registers: |
3870 // elements: Fixed array of strings. | 3874 // elements: Fixed array of strings. |
3871 // array_length: Length of the fixed array of strings (not smi) | 3875 // array_length: Length of the fixed array of strings (not smi) |
3872 // separator: Separator string | 3876 // separator: Separator string |
3873 // string_length: Accumulated sum of string lengths (smi). | 3877 // string_length: Accumulated sum of string lengths (smi). |
3874 // element: Current array element. | 3878 // element: Current array element. |
3875 // elements_end: Array end. | 3879 // elements_end: Array end. |
3876 if (generate_debug_code_) { | 3880 if (generate_debug_code_) { |
3877 __ cmp(array_length, Operand::Zero()); | 3881 __ cmpi(array_length, Operand::Zero()); |
3878 __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin); | 3882 __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin); |
3879 } | 3883 } |
3880 __ bind(&loop); | 3884 __ bind(&loop); |
3881 __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); | 3885 __ LoadP(string, MemOperand(element)); |
| 3886 __ addi(element, element, Operand(kPointerSize)); |
3882 __ JumpIfSmi(string, &bailout); | 3887 __ JumpIfSmi(string, &bailout); |
3883 __ ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset)); | 3888 __ LoadP(scratch1, FieldMemOperand(string, HeapObject::kMapOffset)); |
3884 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | 3889 __ lbz(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); |
3885 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &bailout); | 3890 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); |
3886 __ ldr(scratch, FieldMemOperand(string, SeqOneByteString::kLengthOffset)); | 3891 __ LoadP(scratch1, FieldMemOperand(string, SeqOneByteString::kLengthOffset)); |
3887 __ add(string_length, string_length, Operand(scratch), SetCC); | 3892 |
3888 __ b(vs, &bailout); | 3893 __ AddAndCheckForOverflow(string_length, string_length, scratch1, scratch2, |
| 3894 r0); |
| 3895 __ BranchOnOverflow(&bailout); |
| 3896 |
3889 __ cmp(element, elements_end); | 3897 __ cmp(element, elements_end); |
3890 __ b(lt, &loop); | 3898 __ blt(&loop); |
3891 | 3899 |
3892 // If array_length is 1, return elements[0], a string. | 3900 // If array_length is 1, return elements[0], a string. |
3893 __ cmp(array_length, Operand(1)); | 3901 __ cmpi(array_length, Operand(1)); |
3894 __ b(ne, ¬_size_one_array); | 3902 __ bne(¬_size_one_array); |
3895 __ ldr(r0, FieldMemOperand(elements, FixedArray::kHeaderSize)); | 3903 __ LoadP(r3, FieldMemOperand(elements, FixedArray::kHeaderSize)); |
3896 __ b(&done); | 3904 __ b(&done); |
3897 | 3905 |
3898 __ bind(¬_size_one_array); | 3906 __ bind(¬_size_one_array); |
3899 | 3907 |
3900 // Live values in registers: | 3908 // Live values in registers: |
3901 // separator: Separator string | 3909 // separator: Separator string |
3902 // array_length: Length of the array. | 3910 // array_length: Length of the array. |
3903 // string_length: Sum of string lengths (smi). | 3911 // string_length: Sum of string lengths (smi). |
3904 // elements: FixedArray of strings. | 3912 // elements: FixedArray of strings. |
3905 | 3913 |
3906 // Check that the separator is a flat ASCII string. | 3914 // Check that the separator is a flat ASCII string. |
3907 __ JumpIfSmi(separator, &bailout); | 3915 __ JumpIfSmi(separator, &bailout); |
3908 __ ldr(scratch, FieldMemOperand(separator, HeapObject::kMapOffset)); | 3916 __ LoadP(scratch1, FieldMemOperand(separator, HeapObject::kMapOffset)); |
3909 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | 3917 __ lbz(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); |
3910 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &bailout); | 3918 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); |
3911 | 3919 |
3912 // Add (separator length times array_length) - separator length to the | 3920 // Add (separator length times array_length) - separator length to the |
3913 // string_length to get the length of the result string. array_length is not | 3921 // string_length to get the length of the result string. |
3914 // smi but the other values are, so the result is a smi | 3922 __ LoadP(scratch1, |
3915 __ ldr(scratch, FieldMemOperand(separator, SeqOneByteString::kLengthOffset)); | 3923 FieldMemOperand(separator, SeqOneByteString::kLengthOffset)); |
3916 __ sub(string_length, string_length, Operand(scratch)); | 3924 __ sub(string_length, string_length, scratch1); |
3917 __ smull(scratch, ip, array_length, scratch); | 3925 #if V8_TARGET_ARCH_PPC64 |
| 3926 __ SmiUntag(scratch1, scratch1); |
| 3927 __ Mul(scratch2, array_length, scratch1); |
3918 // Check for smi overflow. No overflow if higher 33 bits of 64-bit result are | 3928 // Check for smi overflow. No overflow if higher 33 bits of 64-bit result are |
3919 // zero. | 3929 // zero. |
3920 __ cmp(ip, Operand::Zero()); | 3930 __ ShiftRightImm(ip, scratch2, Operand(31), SetRC); |
3921 __ b(ne, &bailout); | 3931 __ bne(&bailout, cr0); |
3922 __ tst(scratch, Operand(0x80000000)); | 3932 __ SmiTag(scratch2, scratch2); |
3923 __ b(ne, &bailout); | 3933 #else |
3924 __ add(string_length, string_length, Operand(scratch), SetCC); | 3934 // array_length is not smi but the other values are, so the result is a smi |
3925 __ b(vs, &bailout); | 3935 __ mullw(scratch2, array_length, scratch1); |
| 3936 __ mulhw(ip, array_length, scratch1); |
| 3937 // Check for smi overflow. No overflow if higher 33 bits of 64-bit result are |
| 3938 // zero. |
| 3939 __ cmpi(ip, Operand::Zero()); |
| 3940 __ bne(&bailout); |
| 3941 __ cmpwi(scratch2, Operand::Zero()); |
| 3942 __ blt(&bailout); |
| 3943 #endif |
| 3944 |
| 3945 __ AddAndCheckForOverflow(string_length, string_length, scratch2, scratch1, |
| 3946 r0); |
| 3947 __ BranchOnOverflow(&bailout); |
3926 __ SmiUntag(string_length); | 3948 __ SmiUntag(string_length); |
3927 | 3949 |
3928 // Get first element in the array to free up the elements register to be used | 3950 // Get first element in the array to free up the elements register to be used |
3929 // for the result. | 3951 // for the result. |
3930 __ add(element, | 3952 __ addi(element, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
3931 elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
3932 result = elements; // End of live range for elements. | 3953 result = elements; // End of live range for elements. |
3933 elements = no_reg; | 3954 elements = no_reg; |
3934 // Live values in registers: | 3955 // Live values in registers: |
3935 // element: First array element | 3956 // element: First array element |
3936 // separator: Separator string | 3957 // separator: Separator string |
3937 // string_length: Length of result string (not smi) | 3958 // string_length: Length of result string (not smi) |
3938 // array_length: Length of the array. | 3959 // array_length: Length of the array. |
3939 __ AllocateAsciiString(result, | 3960 __ AllocateAsciiString(result, string_length, scratch1, scratch2, |
3940 string_length, | 3961 elements_end, &bailout); |
3941 scratch, | |
3942 string, // used as scratch | |
3943 elements_end, // used as scratch | |
3944 &bailout); | |
3945 // Prepare for looping. Set up elements_end to end of the array. Set | 3962 // Prepare for looping. Set up elements_end to end of the array. Set |
3946 // result_pos to the position of the result where to write the first | 3963 // result_pos to the position of the result where to write the first |
3947 // character. | 3964 // character. |
3948 __ add(elements_end, element, Operand(array_length, LSL, kPointerSizeLog2)); | 3965 __ ShiftLeftImm(elements_end, array_length, Operand(kPointerSizeLog2)); |
| 3966 __ add(elements_end, element, elements_end); |
3949 result_pos = array_length; // End of live range for array_length. | 3967 result_pos = array_length; // End of live range for array_length. |
3950 array_length = no_reg; | 3968 array_length = no_reg; |
3951 __ add(result_pos, | 3969 __ addi(result_pos, result, |
3952 result, | 3970 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
3953 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | |
3954 | 3971 |
3955 // Check the length of the separator. | 3972 // Check the length of the separator. |
3956 __ ldr(scratch, FieldMemOperand(separator, SeqOneByteString::kLengthOffset)); | 3973 __ LoadP(scratch1, |
3957 __ cmp(scratch, Operand(Smi::FromInt(1))); | 3974 FieldMemOperand(separator, SeqOneByteString::kLengthOffset)); |
3958 __ b(eq, &one_char_separator); | 3975 __ CmpSmiLiteral(scratch1, Smi::FromInt(1), r0); |
3959 __ b(gt, &long_separator); | 3976 __ beq(&one_char_separator); |
| 3977 __ bgt(&long_separator); |
3960 | 3978 |
3961 // Empty separator case | 3979 // Empty separator case |
3962 __ bind(&empty_separator_loop); | 3980 __ bind(&empty_separator_loop); |
3963 // Live values in registers: | 3981 // Live values in registers: |
3964 // result_pos: the position to which we are currently copying characters. | 3982 // result_pos: the position to which we are currently copying characters. |
3965 // element: Current array element. | 3983 // element: Current array element. |
3966 // elements_end: Array end. | 3984 // elements_end: Array end. |
3967 | 3985 |
3968 // Copy next array element to the result. | 3986 // Copy next array element to the result. |
3969 __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); | 3987 __ LoadP(string, MemOperand(element)); |
3970 __ ldr(string_length, FieldMemOperand(string, String::kLengthOffset)); | 3988 __ addi(element, element, Operand(kPointerSize)); |
| 3989 __ LoadP(string_length, FieldMemOperand(string, String::kLengthOffset)); |
3971 __ SmiUntag(string_length); | 3990 __ SmiUntag(string_length); |
3972 __ add(string, | 3991 __ addi(string, string, |
3973 string, | 3992 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
3974 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 3993 __ CopyBytes(string, result_pos, string_length, scratch1); |
3975 __ CopyBytes(string, result_pos, string_length, scratch); | |
3976 __ cmp(element, elements_end); | 3994 __ cmp(element, elements_end); |
3977 __ b(lt, &empty_separator_loop); // End while (element < elements_end). | 3995 __ blt(&empty_separator_loop); // End while (element < elements_end). |
3978 DCHECK(result.is(r0)); | 3996 DCHECK(result.is(r3)); |
3979 __ b(&done); | 3997 __ b(&done); |
3980 | 3998 |
3981 // One-character separator case | 3999 // One-character separator case |
3982 __ bind(&one_char_separator); | 4000 __ bind(&one_char_separator); |
3983 // Replace separator with its ASCII character value. | 4001 // Replace separator with its ASCII character value. |
3984 __ ldrb(separator, FieldMemOperand(separator, SeqOneByteString::kHeaderSize)); | 4002 __ lbz(separator, FieldMemOperand(separator, SeqOneByteString::kHeaderSize)); |
3985 // Jump into the loop after the code that copies the separator, so the first | 4003 // Jump into the loop after the code that copies the separator, so the first |
3986 // element is not preceded by a separator | 4004 // element is not preceded by a separator |
3987 __ jmp(&one_char_separator_loop_entry); | 4005 __ b(&one_char_separator_loop_entry); |
3988 | 4006 |
3989 __ bind(&one_char_separator_loop); | 4007 __ bind(&one_char_separator_loop); |
3990 // Live values in registers: | 4008 // Live values in registers: |
3991 // result_pos: the position to which we are currently copying characters. | 4009 // result_pos: the position to which we are currently copying characters. |
3992 // element: Current array element. | 4010 // element: Current array element. |
3993 // elements_end: Array end. | 4011 // elements_end: Array end. |
3994 // separator: Single separator ASCII char (in lower byte). | 4012 // separator: Single separator ASCII char (in lower byte). |
3995 | 4013 |
3996 // Copy the separator character to the result. | 4014 // Copy the separator character to the result. |
3997 __ strb(separator, MemOperand(result_pos, 1, PostIndex)); | 4015 __ stb(separator, MemOperand(result_pos)); |
| 4016 __ addi(result_pos, result_pos, Operand(1)); |
3998 | 4017 |
3999 // Copy next array element to the result. | 4018 // Copy next array element to the result. |
4000 __ bind(&one_char_separator_loop_entry); | 4019 __ bind(&one_char_separator_loop_entry); |
4001 __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); | 4020 __ LoadP(string, MemOperand(element)); |
4002 __ ldr(string_length, FieldMemOperand(string, String::kLengthOffset)); | 4021 __ addi(element, element, Operand(kPointerSize)); |
| 4022 __ LoadP(string_length, FieldMemOperand(string, String::kLengthOffset)); |
4003 __ SmiUntag(string_length); | 4023 __ SmiUntag(string_length); |
4004 __ add(string, | 4024 __ addi(string, string, |
4005 string, | 4025 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
4006 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 4026 __ CopyBytes(string, result_pos, string_length, scratch1); |
4007 __ CopyBytes(string, result_pos, string_length, scratch); | 4027 __ cmpl(element, elements_end); |
4008 __ cmp(element, elements_end); | 4028 __ blt(&one_char_separator_loop); // End while (element < elements_end). |
4009 __ b(lt, &one_char_separator_loop); // End while (element < elements_end). | 4029 DCHECK(result.is(r3)); |
4010 DCHECK(result.is(r0)); | |
4011 __ b(&done); | 4030 __ b(&done); |
4012 | 4031 |
4013 // Long separator case (separator is more than one character). Entry is at the | 4032 // Long separator case (separator is more than one character). Entry is at the |
4014 // label long_separator below. | 4033 // label long_separator below. |
4015 __ bind(&long_separator_loop); | 4034 __ bind(&long_separator_loop); |
4016 // Live values in registers: | 4035 // Live values in registers: |
4017 // result_pos: the position to which we are currently copying characters. | 4036 // result_pos: the position to which we are currently copying characters. |
4018 // element: Current array element. | 4037 // element: Current array element. |
4019 // elements_end: Array end. | 4038 // elements_end: Array end. |
4020 // separator: Separator string. | 4039 // separator: Separator string. |
4021 | 4040 |
4022 // Copy the separator to the result. | 4041 // Copy the separator to the result. |
4023 __ ldr(string_length, FieldMemOperand(separator, String::kLengthOffset)); | 4042 __ LoadP(string_length, FieldMemOperand(separator, String::kLengthOffset)); |
4024 __ SmiUntag(string_length); | 4043 __ SmiUntag(string_length); |
4025 __ add(string, | 4044 __ addi(string, separator, |
4026 separator, | 4045 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
4027 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 4046 __ CopyBytes(string, result_pos, string_length, scratch1); |
4028 __ CopyBytes(string, result_pos, string_length, scratch); | |
4029 | 4047 |
4030 __ bind(&long_separator); | 4048 __ bind(&long_separator); |
4031 __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); | 4049 __ LoadP(string, MemOperand(element)); |
4032 __ ldr(string_length, FieldMemOperand(string, String::kLengthOffset)); | 4050 __ addi(element, element, Operand(kPointerSize)); |
| 4051 __ LoadP(string_length, FieldMemOperand(string, String::kLengthOffset)); |
4033 __ SmiUntag(string_length); | 4052 __ SmiUntag(string_length); |
4034 __ add(string, | 4053 __ addi(string, string, |
4035 string, | 4054 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
4036 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 4055 __ CopyBytes(string, result_pos, string_length, scratch1); |
4037 __ CopyBytes(string, result_pos, string_length, scratch); | 4056 __ cmpl(element, elements_end); |
4038 __ cmp(element, elements_end); | 4057 __ blt(&long_separator_loop); // End while (element < elements_end). |
4039 __ b(lt, &long_separator_loop); // End while (element < elements_end). | 4058 DCHECK(result.is(r3)); |
4040 DCHECK(result.is(r0)); | |
4041 __ b(&done); | 4059 __ b(&done); |
4042 | 4060 |
4043 __ bind(&bailout); | 4061 __ bind(&bailout); |
4044 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 4062 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
4045 __ bind(&done); | 4063 __ bind(&done); |
4046 context()->Plug(r0); | 4064 context()->Plug(r3); |
4047 } | 4065 } |
4048 | 4066 |
4049 | 4067 |
4050 void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) { | 4068 void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) { |
4051 DCHECK(expr->arguments()->length() == 0); | 4069 DCHECK(expr->arguments()->length() == 0); |
4052 ExternalReference debug_is_active = | 4070 ExternalReference debug_is_active = |
4053 ExternalReference::debug_is_active_address(isolate()); | 4071 ExternalReference::debug_is_active_address(isolate()); |
4054 __ mov(ip, Operand(debug_is_active)); | 4072 __ mov(ip, Operand(debug_is_active)); |
4055 __ ldrb(r0, MemOperand(ip)); | 4073 __ lbz(r3, MemOperand(ip)); |
4056 __ SmiTag(r0); | 4074 __ SmiTag(r3); |
4057 context()->Plug(r0); | 4075 context()->Plug(r3); |
4058 } | 4076 } |
4059 | 4077 |
4060 | 4078 |
4061 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4079 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
4062 if (expr->function() != NULL && | 4080 if (expr->function() != NULL && |
4063 expr->function()->intrinsic_type == Runtime::INLINE) { | 4081 expr->function()->intrinsic_type == Runtime::INLINE) { |
4064 Comment cmnt(masm_, "[ InlineRuntimeCall"); | 4082 Comment cmnt(masm_, "[ InlineRuntimeCall"); |
4065 EmitInlineRuntimeCall(expr); | 4083 EmitInlineRuntimeCall(expr); |
4066 return; | 4084 return; |
4067 } | 4085 } |
4068 | 4086 |
4069 Comment cmnt(masm_, "[ CallRuntime"); | 4087 Comment cmnt(masm_, "[ CallRuntime"); |
4070 ZoneList<Expression*>* args = expr->arguments(); | 4088 ZoneList<Expression*>* args = expr->arguments(); |
4071 int arg_count = args->length(); | 4089 int arg_count = args->length(); |
4072 | 4090 |
4073 if (expr->is_jsruntime()) { | 4091 if (expr->is_jsruntime()) { |
4074 // Push the builtins object as the receiver. | 4092 // Push the builtins object as the receiver. |
4075 Register receiver = LoadIC::ReceiverRegister(); | 4093 Register receiver = LoadIC::ReceiverRegister(); |
4076 __ ldr(receiver, GlobalObjectOperand()); | 4094 __ LoadP(receiver, GlobalObjectOperand()); |
4077 __ ldr(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); | 4095 __ LoadP(receiver, |
| 4096 FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); |
4078 __ push(receiver); | 4097 __ push(receiver); |
4079 | 4098 |
4080 // Load the function from the receiver. | 4099 // Load the function from the receiver. |
4081 __ mov(LoadIC::NameRegister(), Operand(expr->name())); | 4100 __ mov(LoadIC::NameRegister(), Operand(expr->name())); |
4082 if (FLAG_vector_ics) { | 4101 if (FLAG_vector_ics) { |
4083 __ mov(LoadIC::SlotRegister(), | 4102 __ mov(LoadIC::SlotRegister(), |
4084 Operand(Smi::FromInt(expr->CallRuntimeFeedbackSlot()))); | 4103 Operand(Smi::FromInt(expr->CallRuntimeFeedbackSlot()))); |
4085 CallLoadIC(NOT_CONTEXTUAL); | 4104 CallLoadIC(NOT_CONTEXTUAL); |
4086 } else { | 4105 } else { |
4087 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | 4106 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); |
4088 } | 4107 } |
4089 | 4108 |
4090 // Push the target function under the receiver. | 4109 // Push the target function under the receiver. |
4091 __ ldr(ip, MemOperand(sp, 0)); | 4110 __ LoadP(ip, MemOperand(sp, 0)); |
4092 __ push(ip); | 4111 __ push(ip); |
4093 __ str(r0, MemOperand(sp, kPointerSize)); | 4112 __ StoreP(r3, MemOperand(sp, kPointerSize)); |
4094 | 4113 |
4095 // Push the arguments ("left-to-right"). | 4114 // Push the arguments ("left-to-right"). |
4096 int arg_count = args->length(); | 4115 int arg_count = args->length(); |
4097 for (int i = 0; i < arg_count; i++) { | 4116 for (int i = 0; i < arg_count; i++) { |
4098 VisitForStackValue(args->at(i)); | 4117 VisitForStackValue(args->at(i)); |
4099 } | 4118 } |
4100 | 4119 |
4101 // Record source position of the IC call. | 4120 // Record source position of the IC call. |
4102 SetSourcePosition(expr->position()); | 4121 SetSourcePosition(expr->position()); |
4103 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4122 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
4104 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 4123 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
4105 __ CallStub(&stub); | 4124 __ CallStub(&stub); |
4106 | 4125 |
4107 // Restore context register. | 4126 // Restore context register. |
4108 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4127 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
4109 | 4128 |
4110 context()->DropAndPlug(1, r0); | 4129 context()->DropAndPlug(1, r3); |
4111 } else { | 4130 } else { |
4112 // Push the arguments ("left-to-right"). | 4131 // Push the arguments ("left-to-right"). |
4113 for (int i = 0; i < arg_count; i++) { | 4132 for (int i = 0; i < arg_count; i++) { |
4114 VisitForStackValue(args->at(i)); | 4133 VisitForStackValue(args->at(i)); |
4115 } | 4134 } |
4116 | 4135 |
4117 // Call the C runtime function. | 4136 // Call the C runtime function. |
4118 __ CallRuntime(expr->function(), arg_count); | 4137 __ CallRuntime(expr->function(), arg_count); |
4119 context()->Plug(r0); | 4138 context()->Plug(r3); |
4120 } | 4139 } |
4121 } | 4140 } |
4122 | 4141 |
4123 | 4142 |
4124 void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { | 4143 void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
4125 switch (expr->op()) { | 4144 switch (expr->op()) { |
4126 case Token::DELETE: { | 4145 case Token::DELETE: { |
4127 Comment cmnt(masm_, "[ UnaryOperation (DELETE)"); | 4146 Comment cmnt(masm_, "[ UnaryOperation (DELETE)"); |
4128 Property* property = expr->expression()->AsProperty(); | 4147 Property* property = expr->expression()->AsProperty(); |
4129 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 4148 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
4130 | 4149 |
4131 if (property != NULL) { | 4150 if (property != NULL) { |
4132 VisitForStackValue(property->obj()); | 4151 VisitForStackValue(property->obj()); |
4133 VisitForStackValue(property->key()); | 4152 VisitForStackValue(property->key()); |
4134 __ mov(r1, Operand(Smi::FromInt(strict_mode()))); | 4153 __ LoadSmiLiteral(r4, Smi::FromInt(strict_mode())); |
4135 __ push(r1); | 4154 __ push(r4); |
4136 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); | 4155 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); |
4137 context()->Plug(r0); | 4156 context()->Plug(r3); |
4138 } else if (proxy != NULL) { | 4157 } else if (proxy != NULL) { |
4139 Variable* var = proxy->var(); | 4158 Variable* var = proxy->var(); |
4140 // Delete of an unqualified identifier is disallowed in strict mode | 4159 // Delete of an unqualified identifier is disallowed in strict mode |
4141 // but "delete this" is allowed. | 4160 // but "delete this" is allowed. |
4142 DCHECK(strict_mode() == SLOPPY || var->is_this()); | 4161 DCHECK(strict_mode() == SLOPPY || var->is_this()); |
4143 if (var->IsUnallocated()) { | 4162 if (var->IsUnallocated()) { |
4144 __ ldr(r2, GlobalObjectOperand()); | 4163 __ LoadP(r5, GlobalObjectOperand()); |
4145 __ mov(r1, Operand(var->name())); | 4164 __ mov(r4, Operand(var->name())); |
4146 __ mov(r0, Operand(Smi::FromInt(SLOPPY))); | 4165 __ LoadSmiLiteral(r3, Smi::FromInt(SLOPPY)); |
4147 __ Push(r2, r1, r0); | 4166 __ Push(r5, r4, r3); |
4148 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); | 4167 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); |
4149 context()->Plug(r0); | 4168 context()->Plug(r3); |
4150 } else if (var->IsStackAllocated() || var->IsContextSlot()) { | 4169 } else if (var->IsStackAllocated() || var->IsContextSlot()) { |
4151 // Result of deleting non-global, non-dynamic variables is false. | 4170 // Result of deleting non-global, non-dynamic variables is false. |
4152 // The subexpression does not have side effects. | 4171 // The subexpression does not have side effects. |
4153 context()->Plug(var->is_this()); | 4172 context()->Plug(var->is_this()); |
4154 } else { | 4173 } else { |
4155 // Non-global variable. Call the runtime to try to delete from the | 4174 // Non-global variable. Call the runtime to try to delete from the |
4156 // context where the variable was introduced. | 4175 // context where the variable was introduced. |
4157 DCHECK(!context_register().is(r2)); | 4176 DCHECK(!context_register().is(r5)); |
4158 __ mov(r2, Operand(var->name())); | 4177 __ mov(r5, Operand(var->name())); |
4159 __ Push(context_register(), r2); | 4178 __ Push(context_register(), r5); |
4160 __ CallRuntime(Runtime::kDeleteLookupSlot, 2); | 4179 __ CallRuntime(Runtime::kDeleteLookupSlot, 2); |
4161 context()->Plug(r0); | 4180 context()->Plug(r3); |
4162 } | 4181 } |
4163 } else { | 4182 } else { |
4164 // Result of deleting non-property, non-variable reference is true. | 4183 // Result of deleting non-property, non-variable reference is true. |
4165 // The subexpression may have side effects. | 4184 // The subexpression may have side effects. |
4166 VisitForEffect(expr->expression()); | 4185 VisitForEffect(expr->expression()); |
4167 context()->Plug(true); | 4186 context()->Plug(true); |
4168 } | 4187 } |
4169 break; | 4188 break; |
4170 } | 4189 } |
4171 | 4190 |
4172 case Token::VOID: { | 4191 case Token::VOID: { |
4173 Comment cmnt(masm_, "[ UnaryOperation (VOID)"); | 4192 Comment cmnt(masm_, "[ UnaryOperation (VOID)"); |
4174 VisitForEffect(expr->expression()); | 4193 VisitForEffect(expr->expression()); |
4175 context()->Plug(Heap::kUndefinedValueRootIndex); | 4194 context()->Plug(Heap::kUndefinedValueRootIndex); |
4176 break; | 4195 break; |
4177 } | 4196 } |
4178 | 4197 |
4179 case Token::NOT: { | 4198 case Token::NOT: { |
4180 Comment cmnt(masm_, "[ UnaryOperation (NOT)"); | 4199 Comment cmnt(masm_, "[ UnaryOperation (NOT)"); |
4181 if (context()->IsEffect()) { | 4200 if (context()->IsEffect()) { |
4182 // Unary NOT has no side effects so it's only necessary to visit the | 4201 // Unary NOT has no side effects so it's only necessary to visit the |
4183 // subexpression. Match the optimizing compiler by not branching. | 4202 // subexpression. Match the optimizing compiler by not branching. |
4184 VisitForEffect(expr->expression()); | 4203 VisitForEffect(expr->expression()); |
4185 } else if (context()->IsTest()) { | 4204 } else if (context()->IsTest()) { |
4186 const TestContext* test = TestContext::cast(context()); | 4205 const TestContext* test = TestContext::cast(context()); |
4187 // The labels are swapped for the recursive call. | 4206 // The labels are swapped for the recursive call. |
4188 VisitForControl(expr->expression(), | 4207 VisitForControl(expr->expression(), test->false_label(), |
4189 test->false_label(), | 4208 test->true_label(), test->fall_through()); |
4190 test->true_label(), | |
4191 test->fall_through()); | |
4192 context()->Plug(test->true_label(), test->false_label()); | 4209 context()->Plug(test->true_label(), test->false_label()); |
4193 } else { | 4210 } else { |
4194 // We handle value contexts explicitly rather than simply visiting | 4211 // We handle value contexts explicitly rather than simply visiting |
4195 // for control and plugging the control flow into the context, | 4212 // for control and plugging the control flow into the context, |
4196 // because we need to prepare a pair of extra administrative AST ids | 4213 // because we need to prepare a pair of extra administrative AST ids |
4197 // for the optimizing compiler. | 4214 // for the optimizing compiler. |
4198 DCHECK(context()->IsAccumulatorValue() || context()->IsStackValue()); | 4215 DCHECK(context()->IsAccumulatorValue() || context()->IsStackValue()); |
4199 Label materialize_true, materialize_false, done; | 4216 Label materialize_true, materialize_false, done; |
4200 VisitForControl(expr->expression(), | 4217 VisitForControl(expr->expression(), &materialize_false, |
4201 &materialize_false, | 4218 &materialize_true, &materialize_true); |
4202 &materialize_true, | |
4203 &materialize_true); | |
4204 __ bind(&materialize_true); | 4219 __ bind(&materialize_true); |
4205 PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS); | 4220 PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS); |
4206 __ LoadRoot(r0, Heap::kTrueValueRootIndex); | 4221 __ LoadRoot(r3, Heap::kTrueValueRootIndex); |
4207 if (context()->IsStackValue()) __ push(r0); | 4222 if (context()->IsStackValue()) __ push(r3); |
4208 __ jmp(&done); | 4223 __ b(&done); |
4209 __ bind(&materialize_false); | 4224 __ bind(&materialize_false); |
4210 PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS); | 4225 PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS); |
4211 __ LoadRoot(r0, Heap::kFalseValueRootIndex); | 4226 __ LoadRoot(r3, Heap::kFalseValueRootIndex); |
4212 if (context()->IsStackValue()) __ push(r0); | 4227 if (context()->IsStackValue()) __ push(r3); |
4213 __ bind(&done); | 4228 __ bind(&done); |
4214 } | 4229 } |
4215 break; | 4230 break; |
4216 } | 4231 } |
4217 | 4232 |
4218 case Token::TYPEOF: { | 4233 case Token::TYPEOF: { |
4219 Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)"); | 4234 Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)"); |
4220 { StackValueContext context(this); | 4235 { |
| 4236 StackValueContext context(this); |
4221 VisitForTypeofValue(expr->expression()); | 4237 VisitForTypeofValue(expr->expression()); |
4222 } | 4238 } |
4223 __ CallRuntime(Runtime::kTypeof, 1); | 4239 __ CallRuntime(Runtime::kTypeof, 1); |
4224 context()->Plug(r0); | 4240 context()->Plug(r3); |
4225 break; | 4241 break; |
4226 } | 4242 } |
4227 | 4243 |
4228 default: | 4244 default: |
4229 UNREACHABLE(); | 4245 UNREACHABLE(); |
4230 } | 4246 } |
4231 } | 4247 } |
4232 | 4248 |
4233 | 4249 |
4234 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 4250 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
(...skipping 15 matching lines...) Expand all Loading... |
4250 } | 4266 } |
4251 | 4267 |
4252 // Evaluate expression and get value. | 4268 // Evaluate expression and get value. |
4253 if (assign_type == VARIABLE) { | 4269 if (assign_type == VARIABLE) { |
4254 DCHECK(expr->expression()->AsVariableProxy()->var() != NULL); | 4270 DCHECK(expr->expression()->AsVariableProxy()->var() != NULL); |
4255 AccumulatorValueContext context(this); | 4271 AccumulatorValueContext context(this); |
4256 EmitVariableLoad(expr->expression()->AsVariableProxy()); | 4272 EmitVariableLoad(expr->expression()->AsVariableProxy()); |
4257 } else { | 4273 } else { |
4258 // Reserve space for result of postfix operation. | 4274 // Reserve space for result of postfix operation. |
4259 if (expr->is_postfix() && !context()->IsEffect()) { | 4275 if (expr->is_postfix() && !context()->IsEffect()) { |
4260 __ mov(ip, Operand(Smi::FromInt(0))); | 4276 __ LoadSmiLiteral(ip, Smi::FromInt(0)); |
4261 __ push(ip); | 4277 __ push(ip); |
4262 } | 4278 } |
4263 if (assign_type == NAMED_PROPERTY) { | 4279 if (assign_type == NAMED_PROPERTY) { |
4264 // Put the object both on the stack and in the register. | 4280 // Put the object both on the stack and in the register. |
4265 VisitForStackValue(prop->obj()); | 4281 VisitForStackValue(prop->obj()); |
4266 __ ldr(LoadIC::ReceiverRegister(), MemOperand(sp, 0)); | 4282 __ LoadP(LoadIC::ReceiverRegister(), MemOperand(sp, 0)); |
4267 EmitNamedPropertyLoad(prop); | 4283 EmitNamedPropertyLoad(prop); |
4268 } else { | 4284 } else { |
4269 VisitForStackValue(prop->obj()); | 4285 VisitForStackValue(prop->obj()); |
4270 VisitForStackValue(prop->key()); | 4286 VisitForStackValue(prop->key()); |
4271 __ ldr(LoadIC::ReceiverRegister(), MemOperand(sp, 1 * kPointerSize)); | 4287 __ LoadP(LoadIC::ReceiverRegister(), MemOperand(sp, 1 * kPointerSize)); |
4272 __ ldr(LoadIC::NameRegister(), MemOperand(sp, 0)); | 4288 __ LoadP(LoadIC::NameRegister(), MemOperand(sp, 0)); |
4273 EmitKeyedPropertyLoad(prop); | 4289 EmitKeyedPropertyLoad(prop); |
4274 } | 4290 } |
4275 } | 4291 } |
4276 | 4292 |
4277 // We need a second deoptimization point after loading the value | 4293 // We need a second deoptimization point after loading the value |
4278 // in case evaluating the property load my have a side effect. | 4294 // in case evaluating the property load my have a side effect. |
4279 if (assign_type == VARIABLE) { | 4295 if (assign_type == VARIABLE) { |
4280 PrepareForBailout(expr->expression(), TOS_REG); | 4296 PrepareForBailout(expr->expression(), TOS_REG); |
4281 } else { | 4297 } else { |
4282 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 4298 PrepareForBailoutForId(prop->LoadId(), TOS_REG); |
4283 } | 4299 } |
4284 | 4300 |
4285 // Inline smi case if we are in a loop. | 4301 // Inline smi case if we are in a loop. |
4286 Label stub_call, done; | 4302 Label stub_call, done; |
4287 JumpPatchSite patch_site(masm_); | 4303 JumpPatchSite patch_site(masm_); |
4288 | 4304 |
4289 int count_value = expr->op() == Token::INC ? 1 : -1; | 4305 int count_value = expr->op() == Token::INC ? 1 : -1; |
4290 if (ShouldInlineSmiCase(expr->op())) { | 4306 if (ShouldInlineSmiCase(expr->op())) { |
4291 Label slow; | 4307 Label slow; |
4292 patch_site.EmitJumpIfNotSmi(r0, &slow); | 4308 patch_site.EmitJumpIfNotSmi(r3, &slow); |
4293 | 4309 |
4294 // Save result for postfix expressions. | 4310 // Save result for postfix expressions. |
4295 if (expr->is_postfix()) { | 4311 if (expr->is_postfix()) { |
4296 if (!context()->IsEffect()) { | 4312 if (!context()->IsEffect()) { |
4297 // Save the result on the stack. If we have a named or keyed property | 4313 // Save the result on the stack. If we have a named or keyed property |
4298 // we store the result under the receiver that is currently on top | 4314 // we store the result under the receiver that is currently on top |
4299 // of the stack. | 4315 // of the stack. |
4300 switch (assign_type) { | 4316 switch (assign_type) { |
4301 case VARIABLE: | 4317 case VARIABLE: |
4302 __ push(r0); | 4318 __ push(r3); |
4303 break; | 4319 break; |
4304 case NAMED_PROPERTY: | 4320 case NAMED_PROPERTY: |
4305 __ str(r0, MemOperand(sp, kPointerSize)); | 4321 __ StoreP(r3, MemOperand(sp, kPointerSize)); |
4306 break; | 4322 break; |
4307 case KEYED_PROPERTY: | 4323 case KEYED_PROPERTY: |
4308 __ str(r0, MemOperand(sp, 2 * kPointerSize)); | 4324 __ StoreP(r3, MemOperand(sp, 2 * kPointerSize)); |
4309 break; | 4325 break; |
4310 } | 4326 } |
4311 } | 4327 } |
4312 } | 4328 } |
4313 | 4329 |
4314 __ add(r0, r0, Operand(Smi::FromInt(count_value)), SetCC); | 4330 Register scratch1 = r4; |
4315 __ b(vc, &done); | 4331 Register scratch2 = r5; |
| 4332 __ LoadSmiLiteral(scratch1, Smi::FromInt(count_value)); |
| 4333 __ AddAndCheckForOverflow(r3, r3, scratch1, scratch2, r0); |
| 4334 __ BranchOnNoOverflow(&done); |
4316 // Call stub. Undo operation first. | 4335 // Call stub. Undo operation first. |
4317 __ sub(r0, r0, Operand(Smi::FromInt(count_value))); | 4336 __ sub(r3, r3, scratch1); |
4318 __ jmp(&stub_call); | 4337 __ b(&stub_call); |
4319 __ bind(&slow); | 4338 __ bind(&slow); |
4320 } | 4339 } |
4321 ToNumberStub convert_stub(isolate()); | 4340 ToNumberStub convert_stub(isolate()); |
4322 __ CallStub(&convert_stub); | 4341 __ CallStub(&convert_stub); |
4323 | 4342 |
4324 // Save result for postfix expressions. | 4343 // Save result for postfix expressions. |
4325 if (expr->is_postfix()) { | 4344 if (expr->is_postfix()) { |
4326 if (!context()->IsEffect()) { | 4345 if (!context()->IsEffect()) { |
4327 // Save the result on the stack. If we have a named or keyed property | 4346 // Save the result on the stack. If we have a named or keyed property |
4328 // we store the result under the receiver that is currently on top | 4347 // we store the result under the receiver that is currently on top |
4329 // of the stack. | 4348 // of the stack. |
4330 switch (assign_type) { | 4349 switch (assign_type) { |
4331 case VARIABLE: | 4350 case VARIABLE: |
4332 __ push(r0); | 4351 __ push(r3); |
4333 break; | 4352 break; |
4334 case NAMED_PROPERTY: | 4353 case NAMED_PROPERTY: |
4335 __ str(r0, MemOperand(sp, kPointerSize)); | 4354 __ StoreP(r3, MemOperand(sp, kPointerSize)); |
4336 break; | 4355 break; |
4337 case KEYED_PROPERTY: | 4356 case KEYED_PROPERTY: |
4338 __ str(r0, MemOperand(sp, 2 * kPointerSize)); | 4357 __ StoreP(r3, MemOperand(sp, 2 * kPointerSize)); |
4339 break; | 4358 break; |
4340 } | 4359 } |
4341 } | 4360 } |
4342 } | 4361 } |
4343 | 4362 |
4344 | |
4345 __ bind(&stub_call); | 4363 __ bind(&stub_call); |
4346 __ mov(r1, r0); | 4364 __ mr(r4, r3); |
4347 __ mov(r0, Operand(Smi::FromInt(count_value))); | 4365 __ LoadSmiLiteral(r3, Smi::FromInt(count_value)); |
4348 | 4366 |
4349 // Record position before stub call. | 4367 // Record position before stub call. |
4350 SetSourcePosition(expr->position()); | 4368 SetSourcePosition(expr->position()); |
4351 | 4369 |
4352 BinaryOpICStub stub(isolate(), Token::ADD, NO_OVERWRITE); | 4370 BinaryOpICStub stub(isolate(), Token::ADD, NO_OVERWRITE); |
4353 CallIC(stub.GetCode(), expr->CountBinOpFeedbackId()); | 4371 CallIC(stub.GetCode(), expr->CountBinOpFeedbackId()); |
4354 patch_site.EmitPatchInfo(); | 4372 patch_site.EmitPatchInfo(); |
4355 __ bind(&done); | 4373 __ bind(&done); |
4356 | 4374 |
4357 // Store the value returned in r0. | 4375 // Store the value returned in r3. |
4358 switch (assign_type) { | 4376 switch (assign_type) { |
4359 case VARIABLE: | 4377 case VARIABLE: |
4360 if (expr->is_postfix()) { | 4378 if (expr->is_postfix()) { |
4361 { EffectContext context(this); | 4379 { |
| 4380 EffectContext context(this); |
4362 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4381 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
4363 Token::ASSIGN); | 4382 Token::ASSIGN); |
4364 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4383 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4365 context.Plug(r0); | 4384 context.Plug(r3); |
4366 } | 4385 } |
4367 // For all contexts except EffectConstant We have the result on | 4386 // For all contexts except EffectConstant We have the result on |
4368 // top of the stack. | 4387 // top of the stack. |
4369 if (!context()->IsEffect()) { | 4388 if (!context()->IsEffect()) { |
4370 context()->PlugTOS(); | 4389 context()->PlugTOS(); |
4371 } | 4390 } |
4372 } else { | 4391 } else { |
4373 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4392 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
4374 Token::ASSIGN); | 4393 Token::ASSIGN); |
4375 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4394 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4376 context()->Plug(r0); | 4395 context()->Plug(r3); |
4377 } | 4396 } |
4378 break; | 4397 break; |
4379 case NAMED_PROPERTY: { | 4398 case NAMED_PROPERTY: { |
4380 __ mov(StoreIC::NameRegister(), | 4399 __ mov(StoreIC::NameRegister(), |
4381 Operand(prop->key()->AsLiteral()->value())); | 4400 Operand(prop->key()->AsLiteral()->value())); |
4382 __ pop(StoreIC::ReceiverRegister()); | 4401 __ pop(StoreIC::ReceiverRegister()); |
4383 CallStoreIC(expr->CountStoreFeedbackId()); | 4402 CallStoreIC(expr->CountStoreFeedbackId()); |
4384 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4403 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4385 if (expr->is_postfix()) { | 4404 if (expr->is_postfix()) { |
4386 if (!context()->IsEffect()) { | 4405 if (!context()->IsEffect()) { |
4387 context()->PlugTOS(); | 4406 context()->PlugTOS(); |
4388 } | 4407 } |
4389 } else { | 4408 } else { |
4390 context()->Plug(r0); | 4409 context()->Plug(r3); |
4391 } | 4410 } |
4392 break; | 4411 break; |
4393 } | 4412 } |
4394 case KEYED_PROPERTY: { | 4413 case KEYED_PROPERTY: { |
4395 __ Pop(KeyedStoreIC::ReceiverRegister(), KeyedStoreIC::NameRegister()); | 4414 __ Pop(KeyedStoreIC::ReceiverRegister(), KeyedStoreIC::NameRegister()); |
4396 Handle<Code> ic = strict_mode() == SLOPPY | 4415 Handle<Code> ic = |
4397 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 4416 strict_mode() == SLOPPY |
4398 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 4417 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 4418 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
4399 CallIC(ic, expr->CountStoreFeedbackId()); | 4419 CallIC(ic, expr->CountStoreFeedbackId()); |
4400 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4420 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4401 if (expr->is_postfix()) { | 4421 if (expr->is_postfix()) { |
4402 if (!context()->IsEffect()) { | 4422 if (!context()->IsEffect()) { |
4403 context()->PlugTOS(); | 4423 context()->PlugTOS(); |
4404 } | 4424 } |
4405 } else { | 4425 } else { |
4406 context()->Plug(r0); | 4426 context()->Plug(r3); |
4407 } | 4427 } |
4408 break; | 4428 break; |
4409 } | 4429 } |
4410 } | 4430 } |
4411 } | 4431 } |
4412 | 4432 |
4413 | 4433 |
4414 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4434 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
4415 DCHECK(!context()->IsEffect()); | 4435 DCHECK(!context()->IsEffect()); |
4416 DCHECK(!context()->IsTest()); | 4436 DCHECK(!context()->IsTest()); |
4417 VariableProxy* proxy = expr->AsVariableProxy(); | 4437 VariableProxy* proxy = expr->AsVariableProxy(); |
4418 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4438 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
4419 Comment cmnt(masm_, "[ Global variable"); | 4439 Comment cmnt(masm_, "[ Global variable"); |
4420 __ ldr(LoadIC::ReceiverRegister(), GlobalObjectOperand()); | 4440 __ LoadP(LoadIC::ReceiverRegister(), GlobalObjectOperand()); |
4421 __ mov(LoadIC::NameRegister(), Operand(proxy->name())); | 4441 __ mov(LoadIC::NameRegister(), Operand(proxy->name())); |
4422 if (FLAG_vector_ics) { | 4442 if (FLAG_vector_ics) { |
4423 __ mov(LoadIC::SlotRegister(), | 4443 __ mov(LoadIC::SlotRegister(), |
4424 Operand(Smi::FromInt(proxy->VariableFeedbackSlot()))); | 4444 Operand(Smi::FromInt(proxy->VariableFeedbackSlot()))); |
4425 } | 4445 } |
4426 // Use a regular load, not a contextual load, to avoid a reference | 4446 // Use a regular load, not a contextual load, to avoid a reference |
4427 // error. | 4447 // error. |
4428 CallLoadIC(NOT_CONTEXTUAL); | 4448 CallLoadIC(NOT_CONTEXTUAL); |
4429 PrepareForBailout(expr, TOS_REG); | 4449 PrepareForBailout(expr, TOS_REG); |
4430 context()->Plug(r0); | 4450 context()->Plug(r3); |
4431 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 4451 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
4432 Comment cmnt(masm_, "[ Lookup slot"); | 4452 Comment cmnt(masm_, "[ Lookup slot"); |
4433 Label done, slow; | 4453 Label done, slow; |
4434 | 4454 |
4435 // Generate code for loading from variables potentially shadowed | 4455 // Generate code for loading from variables potentially shadowed |
4436 // by eval-introduced variables. | 4456 // by eval-introduced variables. |
4437 EmitDynamicLookupFastCase(proxy, INSIDE_TYPEOF, &slow, &done); | 4457 EmitDynamicLookupFastCase(proxy, INSIDE_TYPEOF, &slow, &done); |
4438 | 4458 |
4439 __ bind(&slow); | 4459 __ bind(&slow); |
4440 __ mov(r0, Operand(proxy->name())); | 4460 __ mov(r3, Operand(proxy->name())); |
4441 __ Push(cp, r0); | 4461 __ Push(cp, r3); |
4442 __ CallRuntime(Runtime::kLoadLookupSlotNoReferenceError, 2); | 4462 __ CallRuntime(Runtime::kLoadLookupSlotNoReferenceError, 2); |
4443 PrepareForBailout(expr, TOS_REG); | 4463 PrepareForBailout(expr, TOS_REG); |
4444 __ bind(&done); | 4464 __ bind(&done); |
4445 | 4465 |
4446 context()->Plug(r0); | 4466 context()->Plug(r3); |
4447 } else { | 4467 } else { |
4448 // This expression cannot throw a reference error at the top level. | 4468 // This expression cannot throw a reference error at the top level. |
4449 VisitInDuplicateContext(expr); | 4469 VisitInDuplicateContext(expr); |
4450 } | 4470 } |
4451 } | 4471 } |
4452 | 4472 |
4453 | 4473 |
4454 void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr, | 4474 void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr, |
4455 Expression* sub_expr, | 4475 Expression* sub_expr, |
4456 Handle<String> check) { | 4476 Handle<String> check) { |
4457 Label materialize_true, materialize_false; | 4477 Label materialize_true, materialize_false; |
4458 Label* if_true = NULL; | 4478 Label* if_true = NULL; |
4459 Label* if_false = NULL; | 4479 Label* if_false = NULL; |
4460 Label* fall_through = NULL; | 4480 Label* fall_through = NULL; |
4461 context()->PrepareTest(&materialize_true, &materialize_false, | 4481 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
4462 &if_true, &if_false, &fall_through); | 4482 &if_false, &fall_through); |
4463 | 4483 |
4464 { AccumulatorValueContext context(this); | 4484 { |
| 4485 AccumulatorValueContext context(this); |
4465 VisitForTypeofValue(sub_expr); | 4486 VisitForTypeofValue(sub_expr); |
4466 } | 4487 } |
4467 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4488 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
4468 | 4489 |
4469 Factory* factory = isolate()->factory(); | 4490 Factory* factory = isolate()->factory(); |
4470 if (String::Equals(check, factory->number_string())) { | 4491 if (String::Equals(check, factory->number_string())) { |
4471 __ JumpIfSmi(r0, if_true); | 4492 __ JumpIfSmi(r3, if_true); |
4472 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 4493 __ LoadP(r3, FieldMemOperand(r3, HeapObject::kMapOffset)); |
4473 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 4494 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
4474 __ cmp(r0, ip); | 4495 __ cmp(r3, ip); |
4475 Split(eq, if_true, if_false, fall_through); | 4496 Split(eq, if_true, if_false, fall_through); |
4476 } else if (String::Equals(check, factory->string_string())) { | 4497 } else if (String::Equals(check, factory->string_string())) { |
4477 __ JumpIfSmi(r0, if_false); | 4498 __ JumpIfSmi(r3, if_false); |
4478 // Check for undetectable objects => false. | 4499 // Check for undetectable objects => false. |
4479 __ CompareObjectType(r0, r0, r1, FIRST_NONSTRING_TYPE); | 4500 __ CompareObjectType(r3, r3, r4, FIRST_NONSTRING_TYPE); |
4480 __ b(ge, if_false); | 4501 __ bge(if_false); |
4481 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); | 4502 __ lbz(r4, FieldMemOperand(r3, Map::kBitFieldOffset)); |
4482 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | 4503 STATIC_ASSERT((1 << Map::kIsUndetectable) < 0x8000); |
4483 Split(eq, if_true, if_false, fall_through); | 4504 __ andi(r0, r4, Operand(1 << Map::kIsUndetectable)); |
| 4505 Split(eq, if_true, if_false, fall_through, cr0); |
4484 } else if (String::Equals(check, factory->symbol_string())) { | 4506 } else if (String::Equals(check, factory->symbol_string())) { |
4485 __ JumpIfSmi(r0, if_false); | 4507 __ JumpIfSmi(r3, if_false); |
4486 __ CompareObjectType(r0, r0, r1, SYMBOL_TYPE); | 4508 __ CompareObjectType(r3, r3, r4, SYMBOL_TYPE); |
4487 Split(eq, if_true, if_false, fall_through); | 4509 Split(eq, if_true, if_false, fall_through); |
4488 } else if (String::Equals(check, factory->boolean_string())) { | 4510 } else if (String::Equals(check, factory->boolean_string())) { |
4489 __ CompareRoot(r0, Heap::kTrueValueRootIndex); | 4511 __ CompareRoot(r3, Heap::kTrueValueRootIndex); |
4490 __ b(eq, if_true); | 4512 __ beq(if_true); |
4491 __ CompareRoot(r0, Heap::kFalseValueRootIndex); | 4513 __ CompareRoot(r3, Heap::kFalseValueRootIndex); |
4492 Split(eq, if_true, if_false, fall_through); | 4514 Split(eq, if_true, if_false, fall_through); |
4493 } else if (String::Equals(check, factory->undefined_string())) { | 4515 } else if (String::Equals(check, factory->undefined_string())) { |
4494 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); | 4516 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
4495 __ b(eq, if_true); | 4517 __ beq(if_true); |
4496 __ JumpIfSmi(r0, if_false); | 4518 __ JumpIfSmi(r3, if_false); |
4497 // Check for undetectable objects => true. | 4519 // Check for undetectable objects => true. |
4498 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 4520 __ LoadP(r3, FieldMemOperand(r3, HeapObject::kMapOffset)); |
4499 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); | 4521 __ lbz(r4, FieldMemOperand(r3, Map::kBitFieldOffset)); |
4500 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | 4522 __ andi(r0, r4, Operand(1 << Map::kIsUndetectable)); |
4501 Split(ne, if_true, if_false, fall_through); | 4523 Split(ne, if_true, if_false, fall_through, cr0); |
4502 | 4524 |
4503 } else if (String::Equals(check, factory->function_string())) { | 4525 } else if (String::Equals(check, factory->function_string())) { |
4504 __ JumpIfSmi(r0, if_false); | 4526 __ JumpIfSmi(r3, if_false); |
4505 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | 4527 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
4506 __ CompareObjectType(r0, r0, r1, JS_FUNCTION_TYPE); | 4528 __ CompareObjectType(r3, r3, r4, JS_FUNCTION_TYPE); |
4507 __ b(eq, if_true); | 4529 __ beq(if_true); |
4508 __ cmp(r1, Operand(JS_FUNCTION_PROXY_TYPE)); | 4530 __ cmpi(r4, Operand(JS_FUNCTION_PROXY_TYPE)); |
4509 Split(eq, if_true, if_false, fall_through); | 4531 Split(eq, if_true, if_false, fall_through); |
4510 } else if (String::Equals(check, factory->object_string())) { | 4532 } else if (String::Equals(check, factory->object_string())) { |
4511 __ JumpIfSmi(r0, if_false); | 4533 __ JumpIfSmi(r3, if_false); |
4512 __ CompareRoot(r0, Heap::kNullValueRootIndex); | 4534 __ CompareRoot(r3, Heap::kNullValueRootIndex); |
4513 __ b(eq, if_true); | 4535 __ beq(if_true); |
4514 // Check for JS objects => true. | 4536 // Check for JS objects => true. |
4515 __ CompareObjectType(r0, r0, r1, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE); | 4537 __ CompareObjectType(r3, r3, r4, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE); |
4516 __ b(lt, if_false); | 4538 __ blt(if_false); |
4517 __ CompareInstanceType(r0, r1, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 4539 __ CompareInstanceType(r3, r4, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
4518 __ b(gt, if_false); | 4540 __ bgt(if_false); |
4519 // Check for undetectable objects => false. | 4541 // Check for undetectable objects => false. |
4520 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); | 4542 __ lbz(r4, FieldMemOperand(r3, Map::kBitFieldOffset)); |
4521 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | 4543 __ andi(r0, r4, Operand(1 << Map::kIsUndetectable)); |
4522 Split(eq, if_true, if_false, fall_through); | 4544 Split(eq, if_true, if_false, fall_through, cr0); |
4523 } else { | 4545 } else { |
4524 if (if_false != fall_through) __ jmp(if_false); | 4546 if (if_false != fall_through) __ b(if_false); |
4525 } | 4547 } |
4526 context()->Plug(if_true, if_false); | 4548 context()->Plug(if_true, if_false); |
4527 } | 4549 } |
4528 | 4550 |
4529 | 4551 |
4530 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 4552 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
4531 Comment cmnt(masm_, "[ CompareOperation"); | 4553 Comment cmnt(masm_, "[ CompareOperation"); |
4532 SetSourcePosition(expr->position()); | 4554 SetSourcePosition(expr->position()); |
4533 | 4555 |
4534 // First we try a fast inlined version of the compare when one of | 4556 // First we try a fast inlined version of the compare when one of |
4535 // the operands is a literal. | 4557 // the operands is a literal. |
4536 if (TryLiteralCompare(expr)) return; | 4558 if (TryLiteralCompare(expr)) return; |
4537 | 4559 |
4538 // Always perform the comparison for its control flow. Pack the result | 4560 // Always perform the comparison for its control flow. Pack the result |
4539 // into the expression's context after the comparison is performed. | 4561 // into the expression's context after the comparison is performed. |
4540 Label materialize_true, materialize_false; | 4562 Label materialize_true, materialize_false; |
4541 Label* if_true = NULL; | 4563 Label* if_true = NULL; |
4542 Label* if_false = NULL; | 4564 Label* if_false = NULL; |
4543 Label* fall_through = NULL; | 4565 Label* fall_through = NULL; |
4544 context()->PrepareTest(&materialize_true, &materialize_false, | 4566 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
4545 &if_true, &if_false, &fall_through); | 4567 &if_false, &fall_through); |
4546 | 4568 |
4547 Token::Value op = expr->op(); | 4569 Token::Value op = expr->op(); |
4548 VisitForStackValue(expr->left()); | 4570 VisitForStackValue(expr->left()); |
4549 switch (op) { | 4571 switch (op) { |
4550 case Token::IN: | 4572 case Token::IN: |
4551 VisitForStackValue(expr->right()); | 4573 VisitForStackValue(expr->right()); |
4552 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION); | 4574 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION); |
4553 PrepareForBailoutBeforeSplit(expr, false, NULL, NULL); | 4575 PrepareForBailoutBeforeSplit(expr, false, NULL, NULL); |
4554 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 4576 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
4555 __ cmp(r0, ip); | 4577 __ cmp(r3, ip); |
4556 Split(eq, if_true, if_false, fall_through); | 4578 Split(eq, if_true, if_false, fall_through); |
4557 break; | 4579 break; |
4558 | 4580 |
4559 case Token::INSTANCEOF: { | 4581 case Token::INSTANCEOF: { |
4560 VisitForStackValue(expr->right()); | 4582 VisitForStackValue(expr->right()); |
4561 InstanceofStub stub(isolate(), InstanceofStub::kNoFlags); | 4583 InstanceofStub stub(isolate(), InstanceofStub::kNoFlags); |
4562 __ CallStub(&stub); | 4584 __ CallStub(&stub); |
4563 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4585 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
4564 // The stub returns 0 for true. | 4586 // The stub returns 0 for true. |
4565 __ tst(r0, r0); | 4587 __ cmpi(r3, Operand::Zero()); |
4566 Split(eq, if_true, if_false, fall_through); | 4588 Split(eq, if_true, if_false, fall_through); |
4567 break; | 4589 break; |
4568 } | 4590 } |
4569 | 4591 |
4570 default: { | 4592 default: { |
4571 VisitForAccumulatorValue(expr->right()); | 4593 VisitForAccumulatorValue(expr->right()); |
4572 Condition cond = CompareIC::ComputeCondition(op); | 4594 Condition cond = CompareIC::ComputeCondition(op); |
4573 __ pop(r1); | 4595 __ pop(r4); |
4574 | 4596 |
4575 bool inline_smi_code = ShouldInlineSmiCase(op); | 4597 bool inline_smi_code = ShouldInlineSmiCase(op); |
4576 JumpPatchSite patch_site(masm_); | 4598 JumpPatchSite patch_site(masm_); |
4577 if (inline_smi_code) { | 4599 if (inline_smi_code) { |
4578 Label slow_case; | 4600 Label slow_case; |
4579 __ orr(r2, r0, Operand(r1)); | 4601 __ orx(r5, r3, r4); |
4580 patch_site.EmitJumpIfNotSmi(r2, &slow_case); | 4602 patch_site.EmitJumpIfNotSmi(r5, &slow_case); |
4581 __ cmp(r1, r0); | 4603 __ cmp(r4, r3); |
4582 Split(cond, if_true, if_false, NULL); | 4604 Split(cond, if_true, if_false, NULL); |
4583 __ bind(&slow_case); | 4605 __ bind(&slow_case); |
4584 } | 4606 } |
4585 | 4607 |
4586 // Record position and call the compare IC. | 4608 // Record position and call the compare IC. |
4587 SetSourcePosition(expr->position()); | 4609 SetSourcePosition(expr->position()); |
4588 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); | 4610 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); |
4589 CallIC(ic, expr->CompareOperationFeedbackId()); | 4611 CallIC(ic, expr->CompareOperationFeedbackId()); |
4590 patch_site.EmitPatchInfo(); | 4612 patch_site.EmitPatchInfo(); |
4591 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4613 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
4592 __ cmp(r0, Operand::Zero()); | 4614 __ cmpi(r3, Operand::Zero()); |
4593 Split(cond, if_true, if_false, fall_through); | 4615 Split(cond, if_true, if_false, fall_through); |
4594 } | 4616 } |
4595 } | 4617 } |
4596 | 4618 |
4597 // Convert the result of the comparison into one expected for this | 4619 // Convert the result of the comparison into one expected for this |
4598 // expression's context. | 4620 // expression's context. |
4599 context()->Plug(if_true, if_false); | 4621 context()->Plug(if_true, if_false); |
4600 } | 4622 } |
4601 | 4623 |
4602 | 4624 |
4603 void FullCodeGenerator::EmitLiteralCompareNil(CompareOperation* expr, | 4625 void FullCodeGenerator::EmitLiteralCompareNil(CompareOperation* expr, |
4604 Expression* sub_expr, | 4626 Expression* sub_expr, |
4605 NilValue nil) { | 4627 NilValue nil) { |
4606 Label materialize_true, materialize_false; | 4628 Label materialize_true, materialize_false; |
4607 Label* if_true = NULL; | 4629 Label* if_true = NULL; |
4608 Label* if_false = NULL; | 4630 Label* if_false = NULL; |
4609 Label* fall_through = NULL; | 4631 Label* fall_through = NULL; |
4610 context()->PrepareTest(&materialize_true, &materialize_false, | 4632 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
4611 &if_true, &if_false, &fall_through); | 4633 &if_false, &fall_through); |
4612 | 4634 |
4613 VisitForAccumulatorValue(sub_expr); | 4635 VisitForAccumulatorValue(sub_expr); |
4614 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4636 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
4615 if (expr->op() == Token::EQ_STRICT) { | 4637 if (expr->op() == Token::EQ_STRICT) { |
4616 Heap::RootListIndex nil_value = nil == kNullValue ? | 4638 Heap::RootListIndex nil_value = nil == kNullValue |
4617 Heap::kNullValueRootIndex : | 4639 ? Heap::kNullValueRootIndex |
4618 Heap::kUndefinedValueRootIndex; | 4640 : Heap::kUndefinedValueRootIndex; |
4619 __ LoadRoot(r1, nil_value); | 4641 __ LoadRoot(r4, nil_value); |
4620 __ cmp(r0, r1); | 4642 __ cmp(r3, r4); |
4621 Split(eq, if_true, if_false, fall_through); | 4643 Split(eq, if_true, if_false, fall_through); |
4622 } else { | 4644 } else { |
4623 Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil); | 4645 Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil); |
4624 CallIC(ic, expr->CompareOperationFeedbackId()); | 4646 CallIC(ic, expr->CompareOperationFeedbackId()); |
4625 __ cmp(r0, Operand(0)); | 4647 __ cmpi(r3, Operand::Zero()); |
4626 Split(ne, if_true, if_false, fall_through); | 4648 Split(ne, if_true, if_false, fall_through); |
4627 } | 4649 } |
4628 context()->Plug(if_true, if_false); | 4650 context()->Plug(if_true, if_false); |
4629 } | 4651 } |
4630 | 4652 |
4631 | 4653 |
4632 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 4654 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
4633 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 4655 __ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
4634 context()->Plug(r0); | 4656 context()->Plug(r3); |
4635 } | 4657 } |
4636 | 4658 |
4637 | 4659 |
4638 Register FullCodeGenerator::result_register() { | 4660 Register FullCodeGenerator::result_register() { return r3; } |
4639 return r0; | |
4640 } | |
4641 | 4661 |
4642 | 4662 |
4643 Register FullCodeGenerator::context_register() { | 4663 Register FullCodeGenerator::context_register() { return cp; } |
4644 return cp; | |
4645 } | |
4646 | 4664 |
4647 | 4665 |
4648 void FullCodeGenerator::StoreToFrameField(int frame_offset, Register value) { | 4666 void FullCodeGenerator::StoreToFrameField(int frame_offset, Register value) { |
4649 DCHECK_EQ(POINTER_SIZE_ALIGN(frame_offset), frame_offset); | 4667 DCHECK_EQ(static_cast<int>(POINTER_SIZE_ALIGN(frame_offset)), frame_offset); |
4650 __ str(value, MemOperand(fp, frame_offset)); | 4668 __ StoreP(value, MemOperand(fp, frame_offset), r0); |
4651 } | 4669 } |
4652 | 4670 |
4653 | 4671 |
4654 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 4672 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
4655 __ ldr(dst, ContextOperand(cp, context_index)); | 4673 __ LoadP(dst, ContextOperand(cp, context_index), r0); |
4656 } | 4674 } |
4657 | 4675 |
4658 | 4676 |
4659 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 4677 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
4660 Scope* declaration_scope = scope()->DeclarationScope(); | 4678 Scope* declaration_scope = scope()->DeclarationScope(); |
4661 if (declaration_scope->is_global_scope() || | 4679 if (declaration_scope->is_global_scope() || |
4662 declaration_scope->is_module_scope()) { | 4680 declaration_scope->is_module_scope()) { |
4663 // Contexts nested in the native context have a canonical empty function | 4681 // Contexts nested in the native context have a canonical empty function |
4664 // as their closure, not the anonymous closure containing the global | 4682 // as their closure, not the anonymous closure containing the global |
4665 // code. Pass a smi sentinel and let the runtime look up the empty | 4683 // code. Pass a smi sentinel and let the runtime look up the empty |
4666 // function. | 4684 // function. |
4667 __ mov(ip, Operand(Smi::FromInt(0))); | 4685 __ LoadSmiLiteral(ip, Smi::FromInt(0)); |
4668 } else if (declaration_scope->is_eval_scope()) { | 4686 } else if (declaration_scope->is_eval_scope()) { |
4669 // Contexts created by a call to eval have the same closure as the | 4687 // Contexts created by a call to eval have the same closure as the |
4670 // context calling eval, not the anonymous closure containing the eval | 4688 // context calling eval, not the anonymous closure containing the eval |
4671 // code. Fetch it from the context. | 4689 // code. Fetch it from the context. |
4672 __ ldr(ip, ContextOperand(cp, Context::CLOSURE_INDEX)); | 4690 __ LoadP(ip, ContextOperand(cp, Context::CLOSURE_INDEX)); |
4673 } else { | 4691 } else { |
4674 DCHECK(declaration_scope->is_function_scope()); | 4692 DCHECK(declaration_scope->is_function_scope()); |
4675 __ ldr(ip, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 4693 __ LoadP(ip, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
4676 } | 4694 } |
4677 __ push(ip); | 4695 __ push(ip); |
4678 } | 4696 } |
4679 | 4697 |
4680 | 4698 |
4681 // ---------------------------------------------------------------------------- | 4699 // ---------------------------------------------------------------------------- |
4682 // Non-local control flow support. | 4700 // Non-local control flow support. |
4683 | 4701 |
4684 void FullCodeGenerator::EnterFinallyBlock() { | 4702 void FullCodeGenerator::EnterFinallyBlock() { |
4685 DCHECK(!result_register().is(r1)); | 4703 DCHECK(!result_register().is(r4)); |
4686 // Store result register while executing finally block. | 4704 // Store result register while executing finally block. |
4687 __ push(result_register()); | 4705 __ push(result_register()); |
4688 // Cook return address in link register to stack (smi encoded Code* delta) | 4706 // Cook return address in link register to stack (smi encoded Code* delta) |
4689 __ sub(r1, lr, Operand(masm_->CodeObject())); | 4707 __ mflr(r4); |
4690 __ SmiTag(r1); | 4708 __ mov(ip, Operand(masm_->CodeObject())); |
| 4709 __ sub(r4, r4, ip); |
| 4710 __ SmiTag(r4); |
4691 | 4711 |
4692 // Store result register while executing finally block. | 4712 // Store result register while executing finally block. |
4693 __ push(r1); | 4713 __ push(r4); |
4694 | 4714 |
4695 // Store pending message while executing finally block. | 4715 // Store pending message while executing finally block. |
4696 ExternalReference pending_message_obj = | 4716 ExternalReference pending_message_obj = |
4697 ExternalReference::address_of_pending_message_obj(isolate()); | 4717 ExternalReference::address_of_pending_message_obj(isolate()); |
4698 __ mov(ip, Operand(pending_message_obj)); | 4718 __ mov(ip, Operand(pending_message_obj)); |
4699 __ ldr(r1, MemOperand(ip)); | 4719 __ LoadP(r4, MemOperand(ip)); |
4700 __ push(r1); | 4720 __ push(r4); |
4701 | 4721 |
4702 ExternalReference has_pending_message = | 4722 ExternalReference has_pending_message = |
4703 ExternalReference::address_of_has_pending_message(isolate()); | 4723 ExternalReference::address_of_has_pending_message(isolate()); |
4704 __ mov(ip, Operand(has_pending_message)); | 4724 __ mov(ip, Operand(has_pending_message)); |
4705 STATIC_ASSERT(sizeof(bool) == 1); // NOLINT(runtime/sizeof) | 4725 __ lbz(r4, MemOperand(ip)); |
4706 __ ldrb(r1, MemOperand(ip)); | 4726 __ SmiTag(r4); |
4707 __ SmiTag(r1); | 4727 __ push(r4); |
4708 __ push(r1); | |
4709 | 4728 |
4710 ExternalReference pending_message_script = | 4729 ExternalReference pending_message_script = |
4711 ExternalReference::address_of_pending_message_script(isolate()); | 4730 ExternalReference::address_of_pending_message_script(isolate()); |
4712 __ mov(ip, Operand(pending_message_script)); | 4731 __ mov(ip, Operand(pending_message_script)); |
4713 __ ldr(r1, MemOperand(ip)); | 4732 __ LoadP(r4, MemOperand(ip)); |
4714 __ push(r1); | 4733 __ push(r4); |
4715 } | 4734 } |
4716 | 4735 |
4717 | 4736 |
4718 void FullCodeGenerator::ExitFinallyBlock() { | 4737 void FullCodeGenerator::ExitFinallyBlock() { |
4719 DCHECK(!result_register().is(r1)); | 4738 DCHECK(!result_register().is(r4)); |
4720 // Restore pending message from stack. | 4739 // Restore pending message from stack. |
4721 __ pop(r1); | 4740 __ pop(r4); |
4722 ExternalReference pending_message_script = | 4741 ExternalReference pending_message_script = |
4723 ExternalReference::address_of_pending_message_script(isolate()); | 4742 ExternalReference::address_of_pending_message_script(isolate()); |
4724 __ mov(ip, Operand(pending_message_script)); | 4743 __ mov(ip, Operand(pending_message_script)); |
4725 __ str(r1, MemOperand(ip)); | 4744 __ StoreP(r4, MemOperand(ip)); |
4726 | 4745 |
4727 __ pop(r1); | 4746 __ pop(r4); |
4728 __ SmiUntag(r1); | 4747 __ SmiUntag(r4); |
4729 ExternalReference has_pending_message = | 4748 ExternalReference has_pending_message = |
4730 ExternalReference::address_of_has_pending_message(isolate()); | 4749 ExternalReference::address_of_has_pending_message(isolate()); |
4731 __ mov(ip, Operand(has_pending_message)); | 4750 __ mov(ip, Operand(has_pending_message)); |
4732 STATIC_ASSERT(sizeof(bool) == 1); // NOLINT(runtime/sizeof) | 4751 __ stb(r4, MemOperand(ip)); |
4733 __ strb(r1, MemOperand(ip)); | |
4734 | 4752 |
4735 __ pop(r1); | 4753 __ pop(r4); |
4736 ExternalReference pending_message_obj = | 4754 ExternalReference pending_message_obj = |
4737 ExternalReference::address_of_pending_message_obj(isolate()); | 4755 ExternalReference::address_of_pending_message_obj(isolate()); |
4738 __ mov(ip, Operand(pending_message_obj)); | 4756 __ mov(ip, Operand(pending_message_obj)); |
4739 __ str(r1, MemOperand(ip)); | 4757 __ StoreP(r4, MemOperand(ip)); |
4740 | 4758 |
4741 // Restore result register from stack. | 4759 // Restore result register from stack. |
4742 __ pop(r1); | 4760 __ pop(r4); |
4743 | 4761 |
4744 // Uncook return address and return. | 4762 // Uncook return address and return. |
4745 __ pop(result_register()); | 4763 __ pop(result_register()); |
4746 __ SmiUntag(r1); | 4764 __ SmiUntag(r4); |
4747 __ add(pc, r1, Operand(masm_->CodeObject())); | 4765 __ mov(ip, Operand(masm_->CodeObject())); |
| 4766 __ add(ip, ip, r4); |
| 4767 __ mtctr(ip); |
| 4768 __ bctr(); |
4748 } | 4769 } |
4749 | 4770 |
4750 | 4771 |
4751 #undef __ | 4772 #undef __ |
4752 | 4773 |
4753 #define __ ACCESS_MASM(masm()) | 4774 #define __ ACCESS_MASM(masm()) |
4754 | 4775 |
4755 FullCodeGenerator::NestedStatement* FullCodeGenerator::TryFinally::Exit( | 4776 FullCodeGenerator::NestedStatement* FullCodeGenerator::TryFinally::Exit( |
4756 int* stack_depth, | 4777 int* stack_depth, int* context_length) { |
4757 int* context_length) { | |
4758 // The macros used here must preserve the result register. | 4778 // The macros used here must preserve the result register. |
4759 | 4779 |
4760 // Because the handler block contains the context of the finally | 4780 // Because the handler block contains the context of the finally |
4761 // code, we can restore it directly from there for the finally code | 4781 // code, we can restore it directly from there for the finally code |
4762 // rather than iteratively unwinding contexts via their previous | 4782 // rather than iteratively unwinding contexts via their previous |
4763 // links. | 4783 // links. |
4764 __ Drop(*stack_depth); // Down to the handler block. | 4784 __ Drop(*stack_depth); // Down to the handler block. |
4765 if (*context_length > 0) { | 4785 if (*context_length > 0) { |
4766 // Restore the context to its dedicated register and the stack. | 4786 // Restore the context to its dedicated register and the stack. |
4767 __ ldr(cp, MemOperand(sp, StackHandlerConstants::kContextOffset)); | 4787 __ LoadP(cp, MemOperand(sp, StackHandlerConstants::kContextOffset)); |
4768 __ str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4788 __ StoreP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
4769 } | 4789 } |
4770 __ PopTryHandler(); | 4790 __ PopTryHandler(); |
4771 __ bl(finally_entry_); | 4791 __ b(finally_entry_, SetLK); |
4772 | 4792 |
4773 *stack_depth = 0; | 4793 *stack_depth = 0; |
4774 *context_length = 0; | 4794 *context_length = 0; |
4775 return previous_; | 4795 return previous_; |
4776 } | 4796 } |
4777 | 4797 |
4778 | |
4779 #undef __ | 4798 #undef __ |
4780 | 4799 |
4781 | 4800 |
4782 static Address GetInterruptImmediateLoadAddress(Address pc) { | 4801 void BackEdgeTable::PatchAt(Code* unoptimized_code, Address pc, |
4783 Address load_address = pc - 2 * Assembler::kInstrSize; | |
4784 if (!FLAG_enable_ool_constant_pool) { | |
4785 DCHECK(Assembler::IsLdrPcImmediateOffset(Memory::int32_at(load_address))); | |
4786 } else if (Assembler::IsLdrPpRegOffset(Memory::int32_at(load_address))) { | |
4787 // This is an extended constant pool lookup. | |
4788 load_address -= 2 * Assembler::kInstrSize; | |
4789 DCHECK(Assembler::IsMovW(Memory::int32_at(load_address))); | |
4790 DCHECK(Assembler::IsMovT( | |
4791 Memory::int32_at(load_address + Assembler::kInstrSize))); | |
4792 } else if (Assembler::IsMovT(Memory::int32_at(load_address))) { | |
4793 // This is a movw_movt immediate load. | |
4794 load_address -= Assembler::kInstrSize; | |
4795 DCHECK(Assembler::IsMovW(Memory::int32_at(load_address))); | |
4796 } else { | |
4797 // This is a small constant pool lookup. | |
4798 DCHECK(Assembler::IsLdrPpImmediateOffset(Memory::int32_at(load_address))); | |
4799 } | |
4800 return load_address; | |
4801 } | |
4802 | |
4803 | |
4804 void BackEdgeTable::PatchAt(Code* unoptimized_code, | |
4805 Address pc, | |
4806 BackEdgeState target_state, | 4802 BackEdgeState target_state, |
4807 Code* replacement_code) { | 4803 Code* replacement_code) { |
4808 Address pc_immediate_load_address = GetInterruptImmediateLoadAddress(pc); | 4804 Address mov_address = Assembler::target_address_from_return_address(pc); |
4809 Address branch_address = pc_immediate_load_address - Assembler::kInstrSize; | 4805 Address cmp_address = mov_address - 2 * Assembler::kInstrSize; |
4810 CodePatcher patcher(branch_address, 1); | 4806 CodePatcher patcher(cmp_address, 1); |
| 4807 |
4811 switch (target_state) { | 4808 switch (target_state) { |
4812 case INTERRUPT: | 4809 case INTERRUPT: { |
4813 { | |
4814 // <decrement profiling counter> | 4810 // <decrement profiling counter> |
4815 // bpl ok | 4811 // cmpi r6, 0 |
4816 // ; load interrupt stub address into ip - either of: | 4812 // bge <ok> ;; not changed |
4817 // ; <small cp load> | <extended cp load> | <immediate load> | 4813 // mov r12, <interrupt stub address> |
4818 // ldr ip, [pc/pp, #imm] | movw ip, #imm | movw ip, #imm | 4814 // mtlr r12 |
4819 // | movt ip, #imm> | movw ip, #imm | 4815 // blrl |
4820 // | ldr ip, [pp, ip] | |
4821 // blx ip | |
4822 // <reset profiling counter> | 4816 // <reset profiling counter> |
4823 // ok-label | 4817 // ok-label |
4824 | 4818 patcher.masm()->cmpi(r6, Operand::Zero()); |
4825 // Calculate branch offset to the ok-label - this is the difference | |
4826 // between the branch address and |pc| (which points at <blx ip>) plus | |
4827 // kProfileCounterResetSequence instructions | |
4828 int branch_offset = pc - Instruction::kPCReadOffset - branch_address + | |
4829 kProfileCounterResetSequenceLength; | |
4830 patcher.masm()->b(branch_offset, pl); | |
4831 break; | 4819 break; |
4832 } | 4820 } |
4833 case ON_STACK_REPLACEMENT: | 4821 case ON_STACK_REPLACEMENT: |
4834 case OSR_AFTER_STACK_CHECK: | 4822 case OSR_AFTER_STACK_CHECK: |
4835 // <decrement profiling counter> | 4823 // <decrement profiling counter> |
4836 // mov r0, r0 (NOP) | 4824 // crset |
4837 // ; load on-stack replacement address into ip - either of: | 4825 // bge <ok> ;; not changed |
4838 // ; <small cp load> | <extended cp load> | <immediate load> | 4826 // mov r12, <on-stack replacement address> |
4839 // ldr ip, [pc/pp, #imm] | movw ip, #imm | movw ip, #imm | 4827 // mtlr r12 |
4840 // | movt ip, #imm> | movw ip, #imm | 4828 // blrl |
4841 // | ldr ip, [pp, ip] | |
4842 // blx ip | |
4843 // <reset profiling counter> | 4829 // <reset profiling counter> |
4844 // ok-label | 4830 // ok-label ----- pc_after points here |
4845 patcher.masm()->nop(); | 4831 |
| 4832 // Set the LT bit such that bge is a NOP |
| 4833 patcher.masm()->crset(Assembler::encode_crbit(cr7, CR_LT)); |
4846 break; | 4834 break; |
4847 } | 4835 } |
4848 | 4836 |
4849 // Replace the call address. | 4837 // Replace the stack check address in the mov sequence with the |
4850 Assembler::set_target_address_at(pc_immediate_load_address, unoptimized_code, | 4838 // entry address of the replacement code. |
4851 replacement_code->entry()); | 4839 Assembler::set_target_address_at(mov_address, unoptimized_code, |
| 4840 replacement_code->entry()); |
4852 | 4841 |
4853 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 4842 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
4854 unoptimized_code, pc_immediate_load_address, replacement_code); | 4843 unoptimized_code, mov_address, replacement_code); |
4855 } | 4844 } |
4856 | 4845 |
4857 | 4846 |
4858 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( | 4847 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( |
4859 Isolate* isolate, | 4848 Isolate* isolate, Code* unoptimized_code, Address pc) { |
4860 Code* unoptimized_code, | 4849 Address mov_address = Assembler::target_address_from_return_address(pc); |
4861 Address pc) { | 4850 Address cmp_address = mov_address - 2 * Assembler::kInstrSize; |
4862 DCHECK(Assembler::IsBlxIp(Memory::int32_at(pc - Assembler::kInstrSize))); | 4851 Address interrupt_address = |
| 4852 Assembler::target_address_at(mov_address, unoptimized_code); |
4863 | 4853 |
4864 Address pc_immediate_load_address = GetInterruptImmediateLoadAddress(pc); | 4854 if (Assembler::IsCmpImmediate(Assembler::instr_at(cmp_address))) { |
4865 Address branch_address = pc_immediate_load_address - Assembler::kInstrSize; | 4855 DCHECK(interrupt_address == isolate->builtins()->InterruptCheck()->entry()); |
4866 Address interrupt_address = Assembler::target_address_at( | |
4867 pc_immediate_load_address, unoptimized_code); | |
4868 | |
4869 if (Assembler::IsBranch(Assembler::instr_at(branch_address))) { | |
4870 DCHECK(interrupt_address == | |
4871 isolate->builtins()->InterruptCheck()->entry()); | |
4872 return INTERRUPT; | 4856 return INTERRUPT; |
4873 } | 4857 } |
4874 | 4858 |
4875 DCHECK(Assembler::IsNop(Assembler::instr_at(branch_address))); | 4859 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); |
4876 | 4860 |
4877 if (interrupt_address == | 4861 if (interrupt_address == isolate->builtins()->OnStackReplacement()->entry()) { |
4878 isolate->builtins()->OnStackReplacement()->entry()) { | |
4879 return ON_STACK_REPLACEMENT; | 4862 return ON_STACK_REPLACEMENT; |
4880 } | 4863 } |
4881 | 4864 |
4882 DCHECK(interrupt_address == | 4865 DCHECK(interrupt_address == |
4883 isolate->builtins()->OsrAfterStackCheck()->entry()); | 4866 isolate->builtins()->OsrAfterStackCheck()->entry()); |
4884 return OSR_AFTER_STACK_CHECK; | 4867 return OSR_AFTER_STACK_CHECK; |
4885 } | 4868 } |
| 4869 } |
| 4870 } // namespace v8::internal |
4886 | 4871 |
4887 | 4872 #endif // V8_TARGET_ARCH_PPC |
4888 } } // namespace v8::internal | |
4889 | |
4890 #endif // V8_TARGET_ARCH_ARM | |
OLD | NEW |