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_ARM | 7 #if V8_TARGET_ARCH_ARM |
8 | 8 |
| 9 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 11 #include "src/codegen.h" |
11 #include "src/compiler.h" | 12 #include "src/compiler.h" |
12 #include "src/debug.h" | 13 #include "src/debug.h" |
13 #include "src/full-codegen.h" | 14 #include "src/full-codegen.h" |
14 #include "src/isolate-inl.h" | 15 #include "src/isolate-inl.h" |
15 #include "src/parser.h" | 16 #include "src/parser.h" |
16 #include "src/scopes.h" | 17 #include "src/scopes.h" |
17 | 18 |
18 #include "src/arm/code-stubs-arm.h" | 19 #include "src/arm/code-stubs-arm.h" |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 | 1047 |
1047 __ cmp(r1, r0); | 1048 __ cmp(r1, r0); |
1048 __ b(ne, &next_test); | 1049 __ b(ne, &next_test); |
1049 __ Drop(1); // Switch value is no longer needed. | 1050 __ Drop(1); // Switch value is no longer needed. |
1050 __ b(clause->body_target()); | 1051 __ b(clause->body_target()); |
1051 __ bind(&slow_case); | 1052 __ bind(&slow_case); |
1052 } | 1053 } |
1053 | 1054 |
1054 // Record position before stub call for type feedback. | 1055 // Record position before stub call for type feedback. |
1055 SetSourcePosition(clause->position()); | 1056 SetSourcePosition(clause->position()); |
1056 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); | 1057 Handle<Code> ic = |
| 1058 CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); |
1057 CallIC(ic, clause->CompareId()); | 1059 CallIC(ic, clause->CompareId()); |
1058 patch_site.EmitPatchInfo(); | 1060 patch_site.EmitPatchInfo(); |
1059 | 1061 |
1060 Label skip; | 1062 Label skip; |
1061 __ b(&skip); | 1063 __ b(&skip); |
1062 PrepareForBailout(clause, TOS_REG); | 1064 PrepareForBailout(clause, TOS_REG); |
1063 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 1065 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
1064 __ cmp(r0, ip); | 1066 __ cmp(r0, ip); |
1065 __ b(ne, &next_test); | 1067 __ b(ne, &next_test); |
1066 __ Drop(1); | 1068 __ Drop(1); |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 __ Push(load_name, r3, r0); // "next", iter, received | 2085 __ Push(load_name, r3, r0); // "next", iter, received |
2084 | 2086 |
2085 // result = receiver[f](arg); | 2087 // result = receiver[f](arg); |
2086 __ bind(&l_call); | 2088 __ bind(&l_call); |
2087 __ ldr(load_receiver, MemOperand(sp, kPointerSize)); | 2089 __ ldr(load_receiver, MemOperand(sp, kPointerSize)); |
2088 __ ldr(load_name, MemOperand(sp, 2 * kPointerSize)); | 2090 __ ldr(load_name, MemOperand(sp, 2 * kPointerSize)); |
2089 if (FLAG_vector_ics) { | 2091 if (FLAG_vector_ics) { |
2090 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2092 __ mov(VectorLoadICDescriptor::SlotRegister(), |
2091 Operand(Smi::FromInt(expr->KeyedLoadFeedbackSlot()))); | 2093 Operand(Smi::FromInt(expr->KeyedLoadFeedbackSlot()))); |
2092 } | 2094 } |
2093 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2095 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2094 CallIC(ic, TypeFeedbackId::None()); | 2096 CallIC(ic, TypeFeedbackId::None()); |
2095 __ mov(r1, r0); | 2097 __ mov(r1, r0); |
2096 __ str(r1, MemOperand(sp, 2 * kPointerSize)); | 2098 __ str(r1, MemOperand(sp, 2 * kPointerSize)); |
2097 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2099 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2098 __ CallStub(&stub); | 2100 __ CallStub(&stub); |
2099 | 2101 |
2100 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2102 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2101 __ Drop(1); // The function is still on the stack; drop it. | 2103 __ Drop(1); // The function is still on the stack; drop it. |
2102 | 2104 |
2103 // if (!result.done) goto l_try; | 2105 // if (!result.done) goto l_try; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2303 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2305 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
2304 CallLoadIC(NOT_CONTEXTUAL); | 2306 CallLoadIC(NOT_CONTEXTUAL); |
2305 } else { | 2307 } else { |
2306 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2308 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); |
2307 } | 2309 } |
2308 } | 2310 } |
2309 | 2311 |
2310 | 2312 |
2311 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2313 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2312 SetSourcePosition(prop->position()); | 2314 SetSourcePosition(prop->position()); |
2313 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2315 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2314 if (FLAG_vector_ics) { | 2316 if (FLAG_vector_ics) { |
2315 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2317 __ mov(VectorLoadICDescriptor::SlotRegister(), |
2316 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2318 Operand(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
2317 CallIC(ic); | 2319 CallIC(ic); |
2318 } else { | 2320 } else { |
2319 CallIC(ic, prop->PropertyFeedbackId()); | 2321 CallIC(ic, prop->PropertyFeedbackId()); |
2320 } | 2322 } |
2321 } | 2323 } |
2322 | 2324 |
2323 | 2325 |
(...skipping 12 matching lines...) Expand all Loading... |
2336 Register right = r0; | 2338 Register right = r0; |
2337 __ pop(left); | 2339 __ pop(left); |
2338 | 2340 |
2339 // Perform combined smi check on both operands. | 2341 // Perform combined smi check on both operands. |
2340 __ orr(scratch1, left, Operand(right)); | 2342 __ orr(scratch1, left, Operand(right)); |
2341 STATIC_ASSERT(kSmiTag == 0); | 2343 STATIC_ASSERT(kSmiTag == 0); |
2342 JumpPatchSite patch_site(masm_); | 2344 JumpPatchSite patch_site(masm_); |
2343 patch_site.EmitJumpIfSmi(scratch1, &smi_case); | 2345 patch_site.EmitJumpIfSmi(scratch1, &smi_case); |
2344 | 2346 |
2345 __ bind(&stub_call); | 2347 __ bind(&stub_call); |
2346 BinaryOpICStub stub(isolate(), op, mode); | 2348 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); |
2347 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); | 2349 CallIC(code, expr->BinaryOperationFeedbackId()); |
2348 patch_site.EmitPatchInfo(); | 2350 patch_site.EmitPatchInfo(); |
2349 __ jmp(&done); | 2351 __ jmp(&done); |
2350 | 2352 |
2351 __ bind(&smi_case); | 2353 __ bind(&smi_case); |
2352 // Smi case. This code works the same way as the smi-smi case in the type | 2354 // Smi case. This code works the same way as the smi-smi case in the type |
2353 // recording binary operation stub, see | 2355 // recording binary operation stub, see |
2354 switch (op) { | 2356 switch (op) { |
2355 case Token::SAR: | 2357 case Token::SAR: |
2356 __ GetLeastBitsFromSmi(scratch1, right, 5); | 2358 __ GetLeastBitsFromSmi(scratch1, right, 5); |
2357 __ mov(right, Operand(left, ASR, scratch1)); | 2359 __ mov(right, Operand(left, ASR, scratch1)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2412 | 2414 |
2413 __ bind(&done); | 2415 __ bind(&done); |
2414 context()->Plug(r0); | 2416 context()->Plug(r0); |
2415 } | 2417 } |
2416 | 2418 |
2417 | 2419 |
2418 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 2420 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, |
2419 Token::Value op, | 2421 Token::Value op, |
2420 OverwriteMode mode) { | 2422 OverwriteMode mode) { |
2421 __ pop(r1); | 2423 __ pop(r1); |
2422 BinaryOpICStub stub(isolate(), op, mode); | 2424 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); |
2423 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2425 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2424 CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); | 2426 CallIC(code, expr->BinaryOperationFeedbackId()); |
2425 patch_site.EmitPatchInfo(); | 2427 patch_site.EmitPatchInfo(); |
2426 context()->Plug(r0); | 2428 context()->Plug(r0); |
2427 } | 2429 } |
2428 | 2430 |
2429 | 2431 |
2430 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2432 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
2431 DCHECK(expr->IsValidReferenceExpression()); | 2433 DCHECK(expr->IsValidReferenceExpression()); |
2432 | 2434 |
2433 // Left-hand side can only be a property, a global or a (parameter or local) | 2435 // Left-hand side can only be a property, a global or a (parameter or local) |
2434 // slot. | 2436 // slot. |
(...skipping 23 matching lines...) Expand all Loading... |
2458 CallStoreIC(); | 2460 CallStoreIC(); |
2459 break; | 2461 break; |
2460 } | 2462 } |
2461 case KEYED_PROPERTY: { | 2463 case KEYED_PROPERTY: { |
2462 __ push(r0); // Preserve value. | 2464 __ push(r0); // Preserve value. |
2463 VisitForStackValue(prop->obj()); | 2465 VisitForStackValue(prop->obj()); |
2464 VisitForAccumulatorValue(prop->key()); | 2466 VisitForAccumulatorValue(prop->key()); |
2465 __ Move(StoreDescriptor::NameRegister(), r0); | 2467 __ Move(StoreDescriptor::NameRegister(), r0); |
2466 __ Pop(StoreDescriptor::ValueRegister(), | 2468 __ Pop(StoreDescriptor::ValueRegister(), |
2467 StoreDescriptor::ReceiverRegister()); | 2469 StoreDescriptor::ReceiverRegister()); |
2468 Handle<Code> ic = strict_mode() == SLOPPY | 2470 Handle<Code> ic = |
2469 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2471 CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); |
2470 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | |
2471 CallIC(ic); | 2472 CallIC(ic); |
2472 break; | 2473 break; |
2473 } | 2474 } |
2474 } | 2475 } |
2475 context()->Plug(r0); | 2476 context()->Plug(r0); |
2476 } | 2477 } |
2477 | 2478 |
2478 | 2479 |
2479 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( | 2480 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
2480 Variable* var, MemOperand location) { | 2481 Variable* var, MemOperand location) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2576 | 2577 |
2577 | 2578 |
2578 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2579 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
2579 // Assignment to a property, using a keyed store IC. | 2580 // Assignment to a property, using a keyed store IC. |
2580 | 2581 |
2581 // Record source code position before IC call. | 2582 // Record source code position before IC call. |
2582 SetSourcePosition(expr->position()); | 2583 SetSourcePosition(expr->position()); |
2583 __ Pop(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister()); | 2584 __ Pop(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister()); |
2584 DCHECK(StoreDescriptor::ValueRegister().is(r0)); | 2585 DCHECK(StoreDescriptor::ValueRegister().is(r0)); |
2585 | 2586 |
2586 Handle<Code> ic = strict_mode() == SLOPPY | 2587 Handle<Code> ic = CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); |
2587 ? isolate()->builtins()->KeyedStoreIC_Initialize() | |
2588 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | |
2589 CallIC(ic, expr->AssignmentFeedbackId()); | 2588 CallIC(ic, expr->AssignmentFeedbackId()); |
2590 | 2589 |
2591 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2590 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2592 context()->Plug(r0); | 2591 context()->Plug(r0); |
2593 } | 2592 } |
2594 | 2593 |
2595 | 2594 |
2596 void FullCodeGenerator::VisitProperty(Property* expr) { | 2595 void FullCodeGenerator::VisitProperty(Property* expr) { |
2597 Comment cmnt(masm_, "[ Property"); | 2596 Comment cmnt(masm_, "[ Property"); |
2598 Expression* key = expr->key(); | 2597 Expression* key = expr->key(); |
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4350 } | 4349 } |
4351 | 4350 |
4352 | 4351 |
4353 __ bind(&stub_call); | 4352 __ bind(&stub_call); |
4354 __ mov(r1, r0); | 4353 __ mov(r1, r0); |
4355 __ mov(r0, Operand(Smi::FromInt(count_value))); | 4354 __ mov(r0, Operand(Smi::FromInt(count_value))); |
4356 | 4355 |
4357 // Record position before stub call. | 4356 // Record position before stub call. |
4358 SetSourcePosition(expr->position()); | 4357 SetSourcePosition(expr->position()); |
4359 | 4358 |
4360 BinaryOpICStub stub(isolate(), Token::ADD, NO_OVERWRITE); | 4359 Handle<Code> code = |
4361 CallIC(stub.GetCode(), expr->CountBinOpFeedbackId()); | 4360 CodeFactory::BinaryOpIC(isolate(), Token::ADD, NO_OVERWRITE).code(); |
| 4361 CallIC(code, expr->CountBinOpFeedbackId()); |
4362 patch_site.EmitPatchInfo(); | 4362 patch_site.EmitPatchInfo(); |
4363 __ bind(&done); | 4363 __ bind(&done); |
4364 | 4364 |
4365 // Store the value returned in r0. | 4365 // Store the value returned in r0. |
4366 switch (assign_type) { | 4366 switch (assign_type) { |
4367 case VARIABLE: | 4367 case VARIABLE: |
4368 if (expr->is_postfix()) { | 4368 if (expr->is_postfix()) { |
4369 { EffectContext context(this); | 4369 { EffectContext context(this); |
4370 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4370 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
4371 Token::ASSIGN); | 4371 Token::ASSIGN); |
(...skipping 23 matching lines...) Expand all Loading... |
4395 context()->PlugTOS(); | 4395 context()->PlugTOS(); |
4396 } | 4396 } |
4397 } else { | 4397 } else { |
4398 context()->Plug(r0); | 4398 context()->Plug(r0); |
4399 } | 4399 } |
4400 break; | 4400 break; |
4401 } | 4401 } |
4402 case KEYED_PROPERTY: { | 4402 case KEYED_PROPERTY: { |
4403 __ Pop(StoreDescriptor::ReceiverRegister(), | 4403 __ Pop(StoreDescriptor::ReceiverRegister(), |
4404 StoreDescriptor::NameRegister()); | 4404 StoreDescriptor::NameRegister()); |
4405 Handle<Code> ic = strict_mode() == SLOPPY | 4405 Handle<Code> ic = |
4406 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 4406 CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); |
4407 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | |
4408 CallIC(ic, expr->CountStoreFeedbackId()); | 4407 CallIC(ic, expr->CountStoreFeedbackId()); |
4409 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4408 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4410 if (expr->is_postfix()) { | 4409 if (expr->is_postfix()) { |
4411 if (!context()->IsEffect()) { | 4410 if (!context()->IsEffect()) { |
4412 context()->PlugTOS(); | 4411 context()->PlugTOS(); |
4413 } | 4412 } |
4414 } else { | 4413 } else { |
4415 context()->Plug(r0); | 4414 context()->Plug(r0); |
4416 } | 4415 } |
4417 break; | 4416 break; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4587 Label slow_case; | 4586 Label slow_case; |
4588 __ orr(r2, r0, Operand(r1)); | 4587 __ orr(r2, r0, Operand(r1)); |
4589 patch_site.EmitJumpIfNotSmi(r2, &slow_case); | 4588 patch_site.EmitJumpIfNotSmi(r2, &slow_case); |
4590 __ cmp(r1, r0); | 4589 __ cmp(r1, r0); |
4591 Split(cond, if_true, if_false, NULL); | 4590 Split(cond, if_true, if_false, NULL); |
4592 __ bind(&slow_case); | 4591 __ bind(&slow_case); |
4593 } | 4592 } |
4594 | 4593 |
4595 // Record position and call the compare IC. | 4594 // Record position and call the compare IC. |
4596 SetSourcePosition(expr->position()); | 4595 SetSourcePosition(expr->position()); |
4597 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); | 4596 Handle<Code> ic = CodeFactory::CompareIC(isolate(), op).code(); |
4598 CallIC(ic, expr->CompareOperationFeedbackId()); | 4597 CallIC(ic, expr->CompareOperationFeedbackId()); |
4599 patch_site.EmitPatchInfo(); | 4598 patch_site.EmitPatchInfo(); |
4600 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4599 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
4601 __ cmp(r0, Operand::Zero()); | 4600 __ cmp(r0, Operand::Zero()); |
4602 Split(cond, if_true, if_false, fall_through); | 4601 Split(cond, if_true, if_false, fall_through); |
4603 } | 4602 } |
4604 } | 4603 } |
4605 | 4604 |
4606 // Convert the result of the comparison into one expected for this | 4605 // Convert the result of the comparison into one expected for this |
4607 // expression's context. | 4606 // expression's context. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4923 | 4922 |
4924 DCHECK(interrupt_address == | 4923 DCHECK(interrupt_address == |
4925 isolate->builtins()->OsrAfterStackCheck()->entry()); | 4924 isolate->builtins()->OsrAfterStackCheck()->entry()); |
4926 return OSR_AFTER_STACK_CHECK; | 4925 return OSR_AFTER_STACK_CHECK; |
4927 } | 4926 } |
4928 | 4927 |
4929 | 4928 |
4930 } } // namespace v8::internal | 4929 } } // namespace v8::internal |
4931 | 4930 |
4932 #endif // V8_TARGET_ARCH_ARM | 4931 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |