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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
10 // | 10 // |
11 // The result_register() for mips is the 'v0' register, which is defined | 11 // The result_register() for mips is the 'v0' register, which is defined |
12 // by the ABI to contain function return values. However, the first | 12 // by the ABI to contain function return values. However, the first |
13 // parameter to a function is defined to be 'a0'. So there are many | 13 // parameter to a function is defined to be 'a0'. So there are many |
14 // places where we have to move a previous result in v0 to a0 for the | 14 // places where we have to move a previous result in v0 to a0 for the |
15 // next call: mov(a0, v0). This is not needed on the other architectures. | 15 // next call: mov(a0, v0). This is not needed on the other architectures. |
16 | 16 |
| 17 #include "src/code-factory.h" |
17 #include "src/code-stubs.h" | 18 #include "src/code-stubs.h" |
18 #include "src/codegen.h" | 19 #include "src/codegen.h" |
19 #include "src/compiler.h" | 20 #include "src/compiler.h" |
20 #include "src/debug.h" | 21 #include "src/debug.h" |
21 #include "src/full-codegen.h" | 22 #include "src/full-codegen.h" |
22 #include "src/isolate-inl.h" | 23 #include "src/isolate-inl.h" |
23 #include "src/parser.h" | 24 #include "src/parser.h" |
24 #include "src/scopes.h" | 25 #include "src/scopes.h" |
25 | 26 |
26 #include "src/mips/code-stubs-mips.h" | 27 #include "src/mips/code-stubs-mips.h" |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 | 1040 |
1040 __ Branch(&next_test, ne, a1, Operand(a0)); | 1041 __ Branch(&next_test, ne, a1, Operand(a0)); |
1041 __ Drop(1); // Switch value is no longer needed. | 1042 __ Drop(1); // Switch value is no longer needed. |
1042 __ Branch(clause->body_target()); | 1043 __ Branch(clause->body_target()); |
1043 | 1044 |
1044 __ bind(&slow_case); | 1045 __ bind(&slow_case); |
1045 } | 1046 } |
1046 | 1047 |
1047 // Record position before stub call for type feedback. | 1048 // Record position before stub call for type feedback. |
1048 SetSourcePosition(clause->position()); | 1049 SetSourcePosition(clause->position()); |
1049 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); | 1050 Handle<Code> ic = |
| 1051 CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); |
1050 CallIC(ic, clause->CompareId()); | 1052 CallIC(ic, clause->CompareId()); |
1051 patch_site.EmitPatchInfo(); | 1053 patch_site.EmitPatchInfo(); |
1052 | 1054 |
1053 Label skip; | 1055 Label skip; |
1054 __ Branch(&skip); | 1056 __ Branch(&skip); |
1055 PrepareForBailout(clause, TOS_REG); | 1057 PrepareForBailout(clause, TOS_REG); |
1056 __ LoadRoot(at, Heap::kTrueValueRootIndex); | 1058 __ LoadRoot(at, Heap::kTrueValueRootIndex); |
1057 __ Branch(&next_test, ne, v0, Operand(at)); | 1059 __ Branch(&next_test, ne, v0, Operand(at)); |
1058 __ Drop(1); | 1060 __ Drop(1); |
1059 __ Branch(clause->body_target()); | 1061 __ Branch(clause->body_target()); |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 __ Push(load_name, a3, a0); // "next", iter, received | 2078 __ Push(load_name, a3, a0); // "next", iter, received |
2077 | 2079 |
2078 // result = receiver[f](arg); | 2080 // result = receiver[f](arg); |
2079 __ bind(&l_call); | 2081 __ bind(&l_call); |
2080 __ lw(load_receiver, MemOperand(sp, kPointerSize)); | 2082 __ lw(load_receiver, MemOperand(sp, kPointerSize)); |
2081 __ lw(load_name, MemOperand(sp, 2 * kPointerSize)); | 2083 __ lw(load_name, MemOperand(sp, 2 * kPointerSize)); |
2082 if (FLAG_vector_ics) { | 2084 if (FLAG_vector_ics) { |
2083 __ li(VectorLoadICDescriptor::SlotRegister(), | 2085 __ li(VectorLoadICDescriptor::SlotRegister(), |
2084 Operand(Smi::FromInt(expr->KeyedLoadFeedbackSlot()))); | 2086 Operand(Smi::FromInt(expr->KeyedLoadFeedbackSlot()))); |
2085 } | 2087 } |
2086 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2088 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2087 CallIC(ic, TypeFeedbackId::None()); | 2089 CallIC(ic, TypeFeedbackId::None()); |
2088 __ mov(a0, v0); | 2090 __ mov(a0, v0); |
2089 __ mov(a1, a0); | 2091 __ mov(a1, a0); |
2090 __ sw(a1, MemOperand(sp, 2 * kPointerSize)); | 2092 __ sw(a1, MemOperand(sp, 2 * kPointerSize)); |
2091 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2093 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2092 __ CallStub(&stub); | 2094 __ CallStub(&stub); |
2093 | 2095 |
2094 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2096 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2095 __ Drop(1); // The function is still on the stack; drop it. | 2097 __ Drop(1); // The function is still on the stack; drop it. |
2096 | 2098 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2286 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
2285 CallLoadIC(NOT_CONTEXTUAL); | 2287 CallLoadIC(NOT_CONTEXTUAL); |
2286 } else { | 2288 } else { |
2287 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2289 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); |
2288 } | 2290 } |
2289 } | 2291 } |
2290 | 2292 |
2291 | 2293 |
2292 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2294 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2293 SetSourcePosition(prop->position()); | 2295 SetSourcePosition(prop->position()); |
2294 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2296 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2295 if (FLAG_vector_ics) { | 2297 if (FLAG_vector_ics) { |
2296 __ li(VectorLoadICDescriptor::SlotRegister(), | 2298 __ li(VectorLoadICDescriptor::SlotRegister(), |
2297 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2299 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
2298 CallIC(ic); | 2300 CallIC(ic); |
2299 } else { | 2301 } else { |
2300 CallIC(ic, prop->PropertyFeedbackId()); | 2302 CallIC(ic, prop->PropertyFeedbackId()); |
2301 } | 2303 } |
2302 } | 2304 } |
2303 | 2305 |
2304 | 2306 |
(...skipping 13 matching lines...) Expand all Loading... |
2318 __ pop(left); | 2320 __ pop(left); |
2319 __ mov(a0, result_register()); | 2321 __ mov(a0, result_register()); |
2320 | 2322 |
2321 // Perform combined smi check on both operands. | 2323 // Perform combined smi check on both operands. |
2322 __ Or(scratch1, left, Operand(right)); | 2324 __ Or(scratch1, left, Operand(right)); |
2323 STATIC_ASSERT(kSmiTag == 0); | 2325 STATIC_ASSERT(kSmiTag == 0); |
2324 JumpPatchSite patch_site(masm_); | 2326 JumpPatchSite patch_site(masm_); |
2325 patch_site.EmitJumpIfSmi(scratch1, &smi_case); | 2327 patch_site.EmitJumpIfSmi(scratch1, &smi_case); |
2326 | 2328 |
2327 __ bind(&stub_call); | 2329 __ bind(&stub_call); |
2328 BinaryOpICStub stub(isolate(), op, mode); | 2330 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); |
2329 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); | 2331 CallIC(code, expr->BinaryOperationFeedbackId()); |
2330 patch_site.EmitPatchInfo(); | 2332 patch_site.EmitPatchInfo(); |
2331 __ jmp(&done); | 2333 __ jmp(&done); |
2332 | 2334 |
2333 __ bind(&smi_case); | 2335 __ bind(&smi_case); |
2334 // Smi case. This code works the same way as the smi-smi case in the type | 2336 // Smi case. This code works the same way as the smi-smi case in the type |
2335 // recording binary operation stub, see | 2337 // recording binary operation stub, see |
2336 switch (op) { | 2338 switch (op) { |
2337 case Token::SAR: | 2339 case Token::SAR: |
2338 __ GetLeastBitsFromSmi(scratch1, right, 5); | 2340 __ GetLeastBitsFromSmi(scratch1, right, 5); |
2339 __ srav(right, left, scratch1); | 2341 __ srav(right, left, scratch1); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2393 __ bind(&done); | 2395 __ bind(&done); |
2394 context()->Plug(v0); | 2396 context()->Plug(v0); |
2395 } | 2397 } |
2396 | 2398 |
2397 | 2399 |
2398 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 2400 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, |
2399 Token::Value op, | 2401 Token::Value op, |
2400 OverwriteMode mode) { | 2402 OverwriteMode mode) { |
2401 __ mov(a0, result_register()); | 2403 __ mov(a0, result_register()); |
2402 __ pop(a1); | 2404 __ pop(a1); |
2403 BinaryOpICStub stub(isolate(), op, mode); | 2405 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); |
2404 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2406 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2405 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); | 2407 CallIC(code, expr->BinaryOperationFeedbackId()); |
2406 patch_site.EmitPatchInfo(); | 2408 patch_site.EmitPatchInfo(); |
2407 context()->Plug(v0); | 2409 context()->Plug(v0); |
2408 } | 2410 } |
2409 | 2411 |
2410 | 2412 |
2411 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2413 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
2412 DCHECK(expr->IsValidReferenceExpression()); | 2414 DCHECK(expr->IsValidReferenceExpression()); |
2413 | 2415 |
2414 // Left-hand side can only be a property, a global or a (parameter or local) | 2416 // Left-hand side can only be a property, a global or a (parameter or local) |
2415 // slot. | 2417 // slot. |
(...skipping 23 matching lines...) Expand all Loading... |
2439 CallStoreIC(); | 2441 CallStoreIC(); |
2440 break; | 2442 break; |
2441 } | 2443 } |
2442 case KEYED_PROPERTY: { | 2444 case KEYED_PROPERTY: { |
2443 __ push(result_register()); // Preserve value. | 2445 __ push(result_register()); // Preserve value. |
2444 VisitForStackValue(prop->obj()); | 2446 VisitForStackValue(prop->obj()); |
2445 VisitForAccumulatorValue(prop->key()); | 2447 VisitForAccumulatorValue(prop->key()); |
2446 __ mov(StoreDescriptor::NameRegister(), result_register()); | 2448 __ mov(StoreDescriptor::NameRegister(), result_register()); |
2447 __ Pop(StoreDescriptor::ValueRegister(), | 2449 __ Pop(StoreDescriptor::ValueRegister(), |
2448 StoreDescriptor::ReceiverRegister()); | 2450 StoreDescriptor::ReceiverRegister()); |
2449 Handle<Code> ic = strict_mode() == SLOPPY | 2451 Handle<Code> ic = |
2450 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2452 CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); |
2451 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | |
2452 CallIC(ic); | 2453 CallIC(ic); |
2453 break; | 2454 break; |
2454 } | 2455 } |
2455 } | 2456 } |
2456 context()->Plug(v0); | 2457 context()->Plug(v0); |
2457 } | 2458 } |
2458 | 2459 |
2459 | 2460 |
2460 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( | 2461 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
2461 Variable* var, MemOperand location) { | 2462 Variable* var, MemOperand location) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2563 SetSourcePosition(expr->position()); | 2564 SetSourcePosition(expr->position()); |
2564 // Call keyed store IC. | 2565 // Call keyed store IC. |
2565 // The arguments are: | 2566 // The arguments are: |
2566 // - a0 is the value, | 2567 // - a0 is the value, |
2567 // - a1 is the key, | 2568 // - a1 is the key, |
2568 // - a2 is the receiver. | 2569 // - a2 is the receiver. |
2569 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 2570 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
2570 __ Pop(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister()); | 2571 __ Pop(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister()); |
2571 DCHECK(StoreDescriptor::ValueRegister().is(a0)); | 2572 DCHECK(StoreDescriptor::ValueRegister().is(a0)); |
2572 | 2573 |
2573 Handle<Code> ic = strict_mode() == SLOPPY | 2574 Handle<Code> ic = CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); |
2574 ? isolate()->builtins()->KeyedStoreIC_Initialize() | |
2575 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | |
2576 CallIC(ic, expr->AssignmentFeedbackId()); | 2575 CallIC(ic, expr->AssignmentFeedbackId()); |
2577 | 2576 |
2578 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2577 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2579 context()->Plug(v0); | 2578 context()->Plug(v0); |
2580 } | 2579 } |
2581 | 2580 |
2582 | 2581 |
2583 void FullCodeGenerator::VisitProperty(Property* expr) { | 2582 void FullCodeGenerator::VisitProperty(Property* expr) { |
2584 Comment cmnt(masm_, "[ Property"); | 2583 Comment cmnt(masm_, "[ Property"); |
2585 Expression* key = expr->key(); | 2584 Expression* key = expr->key(); |
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4366 } | 4365 } |
4367 } | 4366 } |
4368 | 4367 |
4369 __ bind(&stub_call); | 4368 __ bind(&stub_call); |
4370 __ mov(a1, v0); | 4369 __ mov(a1, v0); |
4371 __ li(a0, Operand(Smi::FromInt(count_value))); | 4370 __ li(a0, Operand(Smi::FromInt(count_value))); |
4372 | 4371 |
4373 // Record position before stub call. | 4372 // Record position before stub call. |
4374 SetSourcePosition(expr->position()); | 4373 SetSourcePosition(expr->position()); |
4375 | 4374 |
4376 BinaryOpICStub stub(isolate(), Token::ADD, NO_OVERWRITE); | 4375 Handle<Code> code = |
4377 CallIC(stub.GetCode(), expr->CountBinOpFeedbackId()); | 4376 CodeFactory::BinaryOpIC(isolate(), Token::ADD, NO_OVERWRITE).code(); |
| 4377 CallIC(code, expr->CountBinOpFeedbackId()); |
4378 patch_site.EmitPatchInfo(); | 4378 patch_site.EmitPatchInfo(); |
4379 __ bind(&done); | 4379 __ bind(&done); |
4380 | 4380 |
4381 // Store the value returned in v0. | 4381 // Store the value returned in v0. |
4382 switch (assign_type) { | 4382 switch (assign_type) { |
4383 case VARIABLE: | 4383 case VARIABLE: |
4384 if (expr->is_postfix()) { | 4384 if (expr->is_postfix()) { |
4385 { EffectContext context(this); | 4385 { EffectContext context(this); |
4386 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4386 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
4387 Token::ASSIGN); | 4387 Token::ASSIGN); |
(...skipping 25 matching lines...) Expand all Loading... |
4413 } | 4413 } |
4414 } else { | 4414 } else { |
4415 context()->Plug(v0); | 4415 context()->Plug(v0); |
4416 } | 4416 } |
4417 break; | 4417 break; |
4418 } | 4418 } |
4419 case KEYED_PROPERTY: { | 4419 case KEYED_PROPERTY: { |
4420 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 4420 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
4421 __ Pop(StoreDescriptor::ReceiverRegister(), | 4421 __ Pop(StoreDescriptor::ReceiverRegister(), |
4422 StoreDescriptor::NameRegister()); | 4422 StoreDescriptor::NameRegister()); |
4423 Handle<Code> ic = strict_mode() == SLOPPY | 4423 Handle<Code> ic = |
4424 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 4424 CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); |
4425 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | |
4426 CallIC(ic, expr->CountStoreFeedbackId()); | 4425 CallIC(ic, expr->CountStoreFeedbackId()); |
4427 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4426 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4428 if (expr->is_postfix()) { | 4427 if (expr->is_postfix()) { |
4429 if (!context()->IsEffect()) { | 4428 if (!context()->IsEffect()) { |
4430 context()->PlugTOS(); | 4429 context()->PlugTOS(); |
4431 } | 4430 } |
4432 } else { | 4431 } else { |
4433 context()->Plug(v0); | 4432 context()->Plug(v0); |
4434 } | 4433 } |
4435 break; | 4434 break; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4600 JumpPatchSite patch_site(masm_); | 4599 JumpPatchSite patch_site(masm_); |
4601 if (inline_smi_code) { | 4600 if (inline_smi_code) { |
4602 Label slow_case; | 4601 Label slow_case; |
4603 __ Or(a2, a0, Operand(a1)); | 4602 __ Or(a2, a0, Operand(a1)); |
4604 patch_site.EmitJumpIfNotSmi(a2, &slow_case); | 4603 patch_site.EmitJumpIfNotSmi(a2, &slow_case); |
4605 Split(cc, a1, Operand(a0), if_true, if_false, NULL); | 4604 Split(cc, a1, Operand(a0), if_true, if_false, NULL); |
4606 __ bind(&slow_case); | 4605 __ bind(&slow_case); |
4607 } | 4606 } |
4608 // Record position and call the compare IC. | 4607 // Record position and call the compare IC. |
4609 SetSourcePosition(expr->position()); | 4608 SetSourcePosition(expr->position()); |
4610 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); | 4609 Handle<Code> ic = CodeFactory::CompareIC(isolate(), op).code(); |
4611 CallIC(ic, expr->CompareOperationFeedbackId()); | 4610 CallIC(ic, expr->CompareOperationFeedbackId()); |
4612 patch_site.EmitPatchInfo(); | 4611 patch_site.EmitPatchInfo(); |
4613 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4612 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
4614 Split(cc, v0, Operand(zero_reg), if_true, if_false, fall_through); | 4613 Split(cc, v0, Operand(zero_reg), if_true, if_false, fall_through); |
4615 } | 4614 } |
4616 } | 4615 } |
4617 | 4616 |
4618 // Convert the result of the comparison into one expected for this | 4617 // Convert the result of the comparison into one expected for this |
4619 // expression's context. | 4618 // expression's context. |
4620 context()->Plug(if_true, if_false); | 4619 context()->Plug(if_true, if_false); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4873 Assembler::target_address_at(pc_immediate_load_address)) == | 4872 Assembler::target_address_at(pc_immediate_load_address)) == |
4874 reinterpret_cast<uint32_t>( | 4873 reinterpret_cast<uint32_t>( |
4875 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4874 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4876 return OSR_AFTER_STACK_CHECK; | 4875 return OSR_AFTER_STACK_CHECK; |
4877 } | 4876 } |
4878 | 4877 |
4879 | 4878 |
4880 } } // namespace v8::internal | 4879 } } // namespace v8::internal |
4881 | 4880 |
4882 #endif // V8_TARGET_ARCH_MIPS | 4881 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |