| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
| 6 | 6 |
| 7 // Note on Mips implementation: | 7 // Note on Mips implementation: |
| 8 // | 8 // |
| 9 // The result_register() for mips is the 'v0' register, which is defined | 9 // The result_register() for mips is the 'v0' register, which is defined |
| 10 // by the ABI to contain function return values. However, the first | 10 // by the ABI to contain function return values. However, the first |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 183 } |
| 184 int remaining = locals_count % kMaxPushes; | 184 int remaining = locals_count % kMaxPushes; |
| 185 // Emit the remaining pushes. | 185 // Emit the remaining pushes. |
| 186 __ Subu(sp, sp, Operand(remaining * kPointerSize)); | 186 __ Subu(sp, sp, Operand(remaining * kPointerSize)); |
| 187 for (int i = 0; i < remaining; i++) { | 187 for (int i = 0; i < remaining; i++) { |
| 188 __ sw(t5, MemOperand(sp, i * kPointerSize)); | 188 __ sw(t5, MemOperand(sp, i * kPointerSize)); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool function_in_register = true; | 193 bool function_in_register_a1 = true; |
| 194 | 194 |
| 195 // Possibly allocate a local context. | 195 // Possibly allocate a local context. |
| 196 if (info->scope()->num_heap_slots() > 0) { | 196 if (info->scope()->num_heap_slots() > 0) { |
| 197 Comment cmnt(masm_, "[ Allocate context"); | 197 Comment cmnt(masm_, "[ Allocate context"); |
| 198 // Argument to NewContext is the function, which is still in a1. | 198 // Argument to NewContext is the function, which is still in a1. |
| 199 bool need_write_barrier = true; | 199 bool need_write_barrier = true; |
| 200 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 200 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 201 if (info->scope()->is_script_scope()) { | 201 if (info->scope()->is_script_scope()) { |
| 202 __ push(a1); | 202 __ push(a1); |
| 203 __ Push(info->scope()->GetScopeInfo(info->isolate())); | 203 __ Push(info->scope()->GetScopeInfo(info->isolate())); |
| 204 __ CallRuntime(Runtime::kNewScriptContext, 2); | 204 __ CallRuntime(Runtime::kNewScriptContext, 2); |
| 205 } else if (slots <= FastNewContextStub::kMaximumSlots) { | 205 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
| 206 FastNewContextStub stub(isolate(), slots); | 206 FastNewContextStub stub(isolate(), slots); |
| 207 __ CallStub(&stub); | 207 __ CallStub(&stub); |
| 208 // Result of FastNewContextStub is always in new space. | 208 // Result of FastNewContextStub is always in new space. |
| 209 need_write_barrier = false; | 209 need_write_barrier = false; |
| 210 } else { | 210 } else { |
| 211 __ push(a1); | 211 __ push(a1); |
| 212 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 212 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
| 213 } | 213 } |
| 214 function_in_register = false; | 214 function_in_register_a1 = false; |
| 215 // Context is returned in v0. It replaces the context passed to us. | 215 // Context is returned in v0. It replaces the context passed to us. |
| 216 // It's saved in the stack and kept live in cp. | 216 // It's saved in the stack and kept live in cp. |
| 217 __ mov(cp, v0); | 217 __ mov(cp, v0); |
| 218 __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 218 __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 219 // Copy any necessary parameters into the context. | 219 // Copy any necessary parameters into the context. |
| 220 int num_parameters = info->scope()->num_parameters(); | 220 int num_parameters = info->scope()->num_parameters(); |
| 221 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; | 221 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; |
| 222 for (int i = first_parameter; i < num_parameters; i++) { | 222 for (int i = first_parameter; i < num_parameters; i++) { |
| 223 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); | 223 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
| 224 if (var->IsContextSlot()) { | 224 if (var->IsContextSlot()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 237 } else if (FLAG_debug_code) { | 237 } else if (FLAG_debug_code) { |
| 238 Label done; | 238 Label done; |
| 239 __ JumpIfInNewSpace(cp, a0, &done); | 239 __ JumpIfInNewSpace(cp, a0, &done); |
| 240 __ Abort(kExpectedNewSpaceObject); | 240 __ Abort(kExpectedNewSpaceObject); |
| 241 __ bind(&done); | 241 __ bind(&done); |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 | 246 |
| 247 PrepareForBailoutForId(BailoutId::Prologue(), NO_REGISTERS); |
| 248 // Function register is trashed in case we bailout here. But since that |
| 249 // could happen only when we allocate a context the value of |
| 250 // |function_in_register_a1| is correct. |
| 251 |
| 247 // Possibly set up a local binding to the this function which is used in | 252 // Possibly set up a local binding to the this function which is used in |
| 248 // derived constructors with super calls. | 253 // derived constructors with super calls. |
| 249 Variable* this_function_var = scope()->this_function_var(); | 254 Variable* this_function_var = scope()->this_function_var(); |
| 250 if (this_function_var != nullptr) { | 255 if (this_function_var != nullptr) { |
| 251 Comment cmnt(masm_, "[ This function"); | 256 Comment cmnt(masm_, "[ This function"); |
| 252 if (!function_in_register) { | 257 if (!function_in_register_a1) { |
| 253 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 258 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 254 // The write barrier clobbers register again, keep is marked as such. | 259 // The write barrier clobbers register again, keep it marked as such. |
| 255 } | 260 } |
| 256 SetVar(this_function_var, a1, a2, a3); | 261 SetVar(this_function_var, a1, a2, a3); |
| 257 } | 262 } |
| 258 | 263 |
| 259 Variable* new_target_var = scope()->new_target_var(); | 264 Variable* new_target_var = scope()->new_target_var(); |
| 260 if (new_target_var != nullptr) { | 265 if (new_target_var != nullptr) { |
| 261 Comment cmnt(masm_, "[ new.target"); | 266 Comment cmnt(masm_, "[ new.target"); |
| 262 | 267 |
| 263 // Get the frame pointer for the calling frame. | 268 // Get the frame pointer for the calling frame. |
| 264 __ lw(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 269 __ lw(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 265 | 270 |
| 266 // Skip the arguments adaptor frame if it exists. | 271 // Skip the arguments adaptor frame if it exists. |
| 267 Label check_frame_marker; | 272 Label check_frame_marker; |
| 268 __ lw(a1, MemOperand(a2, StandardFrameConstants::kContextOffset)); | 273 __ lw(a1, MemOperand(a2, StandardFrameConstants::kContextOffset)); |
| 269 __ Branch(&check_frame_marker, ne, a1, | 274 __ Branch(&check_frame_marker, ne, a1, |
| 270 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 275 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 271 __ lw(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); | 276 __ lw(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); |
| 272 | 277 |
| 273 // Check the marker in the calling frame. | 278 // Check the marker in the calling frame. |
| 274 __ bind(&check_frame_marker); | 279 __ bind(&check_frame_marker); |
| 275 __ lw(a1, MemOperand(a2, StandardFrameConstants::kMarkerOffset)); | 280 __ lw(a1, MemOperand(a2, StandardFrameConstants::kMarkerOffset)); |
| 281 function_in_register_a1 = false; |
| 276 | 282 |
| 277 Label non_construct_frame, done; | 283 Label non_construct_frame, done; |
| 278 __ Branch(&non_construct_frame, ne, a1, | 284 __ Branch(&non_construct_frame, ne, a1, |
| 279 Operand(Smi::FromInt(StackFrame::CONSTRUCT))); | 285 Operand(Smi::FromInt(StackFrame::CONSTRUCT))); |
| 280 | 286 |
| 281 __ lw(v0, | 287 __ lw(v0, |
| 282 MemOperand(a2, ConstructFrameConstants::kOriginalConstructorOffset)); | 288 MemOperand(a2, ConstructFrameConstants::kOriginalConstructorOffset)); |
| 283 __ Branch(&done); | 289 __ Branch(&done); |
| 284 | 290 |
| 285 __ bind(&non_construct_frame); | 291 __ bind(&non_construct_frame); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 297 | 303 |
| 298 int num_parameters = info->scope()->num_parameters(); | 304 int num_parameters = info->scope()->num_parameters(); |
| 299 int offset = num_parameters * kPointerSize; | 305 int offset = num_parameters * kPointerSize; |
| 300 | 306 |
| 301 __ Addu(a3, fp, | 307 __ Addu(a3, fp, |
| 302 Operand(StandardFrameConstants::kCallerSPOffset + offset)); | 308 Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
| 303 __ li(a2, Operand(Smi::FromInt(num_parameters))); | 309 __ li(a2, Operand(Smi::FromInt(num_parameters))); |
| 304 __ li(a1, Operand(Smi::FromInt(rest_index))); | 310 __ li(a1, Operand(Smi::FromInt(rest_index))); |
| 305 __ li(a0, Operand(Smi::FromInt(language_mode()))); | 311 __ li(a0, Operand(Smi::FromInt(language_mode()))); |
| 306 __ Push(a3, a2, a1, a0); | 312 __ Push(a3, a2, a1, a0); |
| 313 function_in_register_a1 = false; |
| 307 | 314 |
| 308 RestParamAccessStub stub(isolate()); | 315 RestParamAccessStub stub(isolate()); |
| 309 __ CallStub(&stub); | 316 __ CallStub(&stub); |
| 310 | 317 |
| 311 SetVar(rest_param, v0, a1, a2); | 318 SetVar(rest_param, v0, a1, a2); |
| 312 } | 319 } |
| 313 | 320 |
| 314 Variable* arguments = scope()->arguments(); | 321 Variable* arguments = scope()->arguments(); |
| 315 if (arguments != NULL) { | 322 if (arguments != NULL) { |
| 316 // Function uses arguments object. | 323 // Function uses arguments object. |
| 317 Comment cmnt(masm_, "[ Allocate arguments object"); | 324 Comment cmnt(masm_, "[ Allocate arguments object"); |
| 318 if (!function_in_register) { | 325 if (!function_in_register_a1) { |
| 319 // Load this again, if it's used by the local context below. | 326 // Load this again, if it's used by the local context below. |
| 320 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 327 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 321 } else { | 328 } else { |
| 322 __ mov(a3, a1); | 329 __ mov(a3, a1); |
| 323 } | 330 } |
| 324 // Receiver is just before the parameters on the caller's stack. | 331 // Receiver is just before the parameters on the caller's stack. |
| 325 int num_parameters = info->scope()->num_parameters(); | 332 int num_parameters = info->scope()->num_parameters(); |
| 326 int offset = num_parameters * kPointerSize; | 333 int offset = num_parameters * kPointerSize; |
| 327 __ Addu(a2, fp, | 334 __ Addu(a2, fp, |
| 328 Operand(StandardFrameConstants::kCallerSPOffset + offset)); | 335 Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
| (...skipping 5008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5337 reinterpret_cast<uint32_t>( | 5344 reinterpret_cast<uint32_t>( |
| 5338 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5345 isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 5339 return OSR_AFTER_STACK_CHECK; | 5346 return OSR_AFTER_STACK_CHECK; |
| 5340 } | 5347 } |
| 5341 | 5348 |
| 5342 | 5349 |
| 5343 } // namespace internal | 5350 } // namespace internal |
| 5344 } // namespace v8 | 5351 } // namespace v8 |
| 5345 | 5352 |
| 5346 #endif // V8_TARGET_ARCH_MIPS | 5353 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |