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_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
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/mips64/code-stubs-mips64.h" | 27 #include "src/mips64/code-stubs-mips64.h" |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 | 1035 |
1035 __ Branch(&next_test, ne, a1, Operand(a0)); | 1036 __ Branch(&next_test, ne, a1, Operand(a0)); |
1036 __ Drop(1); // Switch value is no longer needed. | 1037 __ Drop(1); // Switch value is no longer needed. |
1037 __ Branch(clause->body_target()); | 1038 __ Branch(clause->body_target()); |
1038 | 1039 |
1039 __ bind(&slow_case); | 1040 __ bind(&slow_case); |
1040 } | 1041 } |
1041 | 1042 |
1042 // Record position before stub call for type feedback. | 1043 // Record position before stub call for type feedback. |
1043 SetSourcePosition(clause->position()); | 1044 SetSourcePosition(clause->position()); |
1044 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); | 1045 Handle<Code> ic = |
| 1046 CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); |
1045 CallIC(ic, clause->CompareId()); | 1047 CallIC(ic, clause->CompareId()); |
1046 patch_site.EmitPatchInfo(); | 1048 patch_site.EmitPatchInfo(); |
1047 | 1049 |
1048 Label skip; | 1050 Label skip; |
1049 __ Branch(&skip); | 1051 __ Branch(&skip); |
1050 PrepareForBailout(clause, TOS_REG); | 1052 PrepareForBailout(clause, TOS_REG); |
1051 __ LoadRoot(at, Heap::kTrueValueRootIndex); | 1053 __ LoadRoot(at, Heap::kTrueValueRootIndex); |
1052 __ Branch(&next_test, ne, v0, Operand(at)); | 1054 __ Branch(&next_test, ne, v0, Operand(at)); |
1053 __ Drop(1); | 1055 __ Drop(1); |
1054 __ Branch(clause->body_target()); | 1056 __ Branch(clause->body_target()); |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 __ Push(load_name, a3, a0); // "next", iter, received | 2073 __ Push(load_name, a3, a0); // "next", iter, received |
2072 | 2074 |
2073 // result = receiver[f](arg); | 2075 // result = receiver[f](arg); |
2074 __ bind(&l_call); | 2076 __ bind(&l_call); |
2075 __ ld(load_receiver, MemOperand(sp, kPointerSize)); | 2077 __ ld(load_receiver, MemOperand(sp, kPointerSize)); |
2076 __ ld(load_name, MemOperand(sp, 2 * kPointerSize)); | 2078 __ ld(load_name, MemOperand(sp, 2 * kPointerSize)); |
2077 if (FLAG_vector_ics) { | 2079 if (FLAG_vector_ics) { |
2078 __ li(VectorLoadICDescriptor::SlotRegister(), | 2080 __ li(VectorLoadICDescriptor::SlotRegister(), |
2079 Operand(Smi::FromInt(expr->KeyedLoadFeedbackSlot()))); | 2081 Operand(Smi::FromInt(expr->KeyedLoadFeedbackSlot()))); |
2080 } | 2082 } |
2081 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2083 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2082 CallIC(ic, TypeFeedbackId::None()); | 2084 CallIC(ic, TypeFeedbackId::None()); |
2083 __ mov(a0, v0); | 2085 __ mov(a0, v0); |
2084 __ mov(a1, a0); | 2086 __ mov(a1, a0); |
2085 __ sd(a1, MemOperand(sp, 2 * kPointerSize)); | 2087 __ sd(a1, MemOperand(sp, 2 * kPointerSize)); |
2086 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2088 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2087 __ CallStub(&stub); | 2089 __ CallStub(&stub); |
2088 | 2090 |
2089 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2091 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2090 __ Drop(1); // The function is still on the stack; drop it. | 2092 __ Drop(1); // The function is still on the stack; drop it. |
2091 | 2093 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 CallLoadIC(NOT_CONTEXTUAL); | 2284 CallLoadIC(NOT_CONTEXTUAL); |
2283 } else { | 2285 } else { |
2284 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2286 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); |
2285 } | 2287 } |
2286 } | 2288 } |
2287 | 2289 |
2288 | 2290 |
2289 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2291 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2290 SetSourcePosition(prop->position()); | 2292 SetSourcePosition(prop->position()); |
2291 // Call keyed load IC. It has register arguments receiver and key. | 2293 // Call keyed load IC. It has register arguments receiver and key. |
2292 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2294 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2293 if (FLAG_vector_ics) { | 2295 if (FLAG_vector_ics) { |
2294 __ li(VectorLoadICDescriptor::SlotRegister(), | 2296 __ li(VectorLoadICDescriptor::SlotRegister(), |
2295 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2297 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
2296 CallIC(ic); | 2298 CallIC(ic); |
2297 } else { | 2299 } else { |
2298 CallIC(ic, prop->PropertyFeedbackId()); | 2300 CallIC(ic, prop->PropertyFeedbackId()); |
2299 } | 2301 } |
2300 } | 2302 } |
2301 | 2303 |
2302 | 2304 |
(...skipping 13 matching lines...) Expand all Loading... |
2316 __ pop(left); | 2318 __ pop(left); |
2317 __ mov(a0, result_register()); | 2319 __ mov(a0, result_register()); |
2318 | 2320 |
2319 // Perform combined smi check on both operands. | 2321 // Perform combined smi check on both operands. |
2320 __ Or(scratch1, left, Operand(right)); | 2322 __ Or(scratch1, left, Operand(right)); |
2321 STATIC_ASSERT(kSmiTag == 0); | 2323 STATIC_ASSERT(kSmiTag == 0); |
2322 JumpPatchSite patch_site(masm_); | 2324 JumpPatchSite patch_site(masm_); |
2323 patch_site.EmitJumpIfSmi(scratch1, &smi_case); | 2325 patch_site.EmitJumpIfSmi(scratch1, &smi_case); |
2324 | 2326 |
2325 __ bind(&stub_call); | 2327 __ bind(&stub_call); |
2326 BinaryOpICStub stub(isolate(), op, mode); | 2328 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); |
2327 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); | 2329 CallIC(code, expr->BinaryOperationFeedbackId()); |
2328 patch_site.EmitPatchInfo(); | 2330 patch_site.EmitPatchInfo(); |
2329 __ jmp(&done); | 2331 __ jmp(&done); |
2330 | 2332 |
2331 __ bind(&smi_case); | 2333 __ bind(&smi_case); |
2332 // Smi case. This code works the same way as the smi-smi case in the type | 2334 // Smi case. This code works the same way as the smi-smi case in the type |
2333 // recording binary operation stub, see | 2335 // recording binary operation stub, see |
2334 switch (op) { | 2336 switch (op) { |
2335 case Token::SAR: | 2337 case Token::SAR: |
2336 __ GetLeastBitsFromSmi(scratch1, right, 5); | 2338 __ GetLeastBitsFromSmi(scratch1, right, 5); |
2337 __ dsrav(right, left, scratch1); | 2339 __ dsrav(right, left, scratch1); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2390 __ bind(&done); | 2392 __ bind(&done); |
2391 context()->Plug(v0); | 2393 context()->Plug(v0); |
2392 } | 2394 } |
2393 | 2395 |
2394 | 2396 |
2395 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 2397 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, |
2396 Token::Value op, | 2398 Token::Value op, |
2397 OverwriteMode mode) { | 2399 OverwriteMode mode) { |
2398 __ mov(a0, result_register()); | 2400 __ mov(a0, result_register()); |
2399 __ pop(a1); | 2401 __ pop(a1); |
2400 BinaryOpICStub stub(isolate(), op, mode); | 2402 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); |
2401 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2403 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2402 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); | 2404 CallIC(code, expr->BinaryOperationFeedbackId()); |
2403 patch_site.EmitPatchInfo(); | 2405 patch_site.EmitPatchInfo(); |
2404 context()->Plug(v0); | 2406 context()->Plug(v0); |
2405 } | 2407 } |
2406 | 2408 |
2407 | 2409 |
2408 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2410 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
2409 DCHECK(expr->IsValidReferenceExpression()); | 2411 DCHECK(expr->IsValidReferenceExpression()); |
2410 | 2412 |
2411 // Left-hand side can only be a property, a global or a (parameter or local) | 2413 // Left-hand side can only be a property, a global or a (parameter or local) |
2412 // slot. | 2414 // slot. |
(...skipping 23 matching lines...) Expand all Loading... |
2436 CallStoreIC(); | 2438 CallStoreIC(); |
2437 break; | 2439 break; |
2438 } | 2440 } |
2439 case KEYED_PROPERTY: { | 2441 case KEYED_PROPERTY: { |
2440 __ push(result_register()); // Preserve value. | 2442 __ push(result_register()); // Preserve value. |
2441 VisitForStackValue(prop->obj()); | 2443 VisitForStackValue(prop->obj()); |
2442 VisitForAccumulatorValue(prop->key()); | 2444 VisitForAccumulatorValue(prop->key()); |
2443 __ Move(StoreDescriptor::NameRegister(), result_register()); | 2445 __ Move(StoreDescriptor::NameRegister(), result_register()); |
2444 __ Pop(StoreDescriptor::ValueRegister(), | 2446 __ Pop(StoreDescriptor::ValueRegister(), |
2445 StoreDescriptor::ReceiverRegister()); | 2447 StoreDescriptor::ReceiverRegister()); |
2446 Handle<Code> ic = strict_mode() == SLOPPY | 2448 Handle<Code> ic = |
2447 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2449 CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); |
2448 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | |
2449 CallIC(ic); | 2450 CallIC(ic); |
2450 break; | 2451 break; |
2451 } | 2452 } |
2452 } | 2453 } |
2453 context()->Plug(v0); | 2454 context()->Plug(v0); |
2454 } | 2455 } |
2455 | 2456 |
2456 | 2457 |
2457 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( | 2458 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
2458 Variable* var, MemOperand location) { | 2459 Variable* var, MemOperand location) { |
(...skipping 104 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4877 Assembler::target_address_at(pc_immediate_load_address)) == | 4876 Assembler::target_address_at(pc_immediate_load_address)) == |
4878 reinterpret_cast<uint64_t>( | 4877 reinterpret_cast<uint64_t>( |
4879 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4878 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4880 return OSR_AFTER_STACK_CHECK; | 4879 return OSR_AFTER_STACK_CHECK; |
4881 } | 4880 } |
4882 | 4881 |
4883 | 4882 |
4884 } } // namespace v8::internal | 4883 } } // namespace v8::internal |
4885 | 4884 |
4886 #endif // V8_TARGET_ARCH_MIPS64 | 4885 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |