OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 if (false_label_ != fall_through_) __ jmp(false_label_); | 622 if (false_label_ != fall_through_) __ jmp(false_label_); |
623 } | 623 } |
624 } | 624 } |
625 | 625 |
626 | 626 |
627 void FullCodeGenerator::DoTest(Expression* condition, | 627 void FullCodeGenerator::DoTest(Expression* condition, |
628 Label* if_true, | 628 Label* if_true, |
629 Label* if_false, | 629 Label* if_false, |
630 Label* fall_through) { | 630 Label* fall_through) { |
631 Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate()); | 631 Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate()); |
632 CallIC(ic, NOT_CONTEXTUAL, condition->test_id()); | 632 CallIC(ic, condition->test_id()); |
633 __ test(result_register(), result_register()); | 633 __ test(result_register(), result_register()); |
634 // The stub returns nonzero for true. | 634 // The stub returns nonzero for true. |
635 Split(not_zero, if_true, if_false, fall_through); | 635 Split(not_zero, if_true, if_false, fall_through); |
636 } | 636 } |
637 | 637 |
638 | 638 |
639 void FullCodeGenerator::Split(Condition cc, | 639 void FullCodeGenerator::Split(Condition cc, |
640 Label* if_true, | 640 Label* if_true, |
641 Label* if_false, | 641 Label* if_false, |
642 Label* fall_through) { | 642 Label* fall_through) { |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 __ cmp(edx, eax); | 973 __ cmp(edx, eax); |
974 __ j(not_equal, &next_test); | 974 __ j(not_equal, &next_test); |
975 __ Drop(1); // Switch value is no longer needed. | 975 __ Drop(1); // Switch value is no longer needed. |
976 __ jmp(clause->body_target()); | 976 __ jmp(clause->body_target()); |
977 __ bind(&slow_case); | 977 __ bind(&slow_case); |
978 } | 978 } |
979 | 979 |
980 // Record position before stub call for type feedback. | 980 // Record position before stub call for type feedback. |
981 SetSourcePosition(clause->position()); | 981 SetSourcePosition(clause->position()); |
982 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); | 982 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); |
983 CallIC(ic, NOT_CONTEXTUAL, clause->CompareId()); | 983 CallIC(ic, clause->CompareId()); |
984 patch_site.EmitPatchInfo(); | 984 patch_site.EmitPatchInfo(); |
985 | 985 |
986 Label skip; | 986 Label skip; |
987 __ jmp(&skip, Label::kNear); | 987 __ jmp(&skip, Label::kNear); |
988 PrepareForBailout(clause, TOS_REG); | 988 PrepareForBailout(clause, TOS_REG); |
989 __ cmp(eax, isolate()->factory()->true_value()); | 989 __ cmp(eax, isolate()->factory()->true_value()); |
990 __ j(not_equal, &next_test); | 990 __ j(not_equal, &next_test); |
991 __ Drop(1); | 991 __ Drop(1); |
992 __ jmp(clause->body_target()); | 992 __ jmp(clause->body_target()); |
993 __ bind(&skip); | 993 __ bind(&skip); |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 UNREACHABLE(); | 1633 UNREACHABLE(); |
1634 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1634 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1635 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); | 1635 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
1636 // Fall through. | 1636 // Fall through. |
1637 case ObjectLiteral::Property::COMPUTED: | 1637 case ObjectLiteral::Property::COMPUTED: |
1638 if (key->value()->IsInternalizedString()) { | 1638 if (key->value()->IsInternalizedString()) { |
1639 if (property->emit_store()) { | 1639 if (property->emit_store()) { |
1640 VisitForAccumulatorValue(value); | 1640 VisitForAccumulatorValue(value); |
1641 __ mov(ecx, Immediate(key->value())); | 1641 __ mov(ecx, Immediate(key->value())); |
1642 __ mov(edx, Operand(esp, 0)); | 1642 __ mov(edx, Operand(esp, 0)); |
1643 CallStoreIC(NOT_CONTEXTUAL, key->LiteralFeedbackId()); | 1643 CallStoreIC(key->LiteralFeedbackId()); |
1644 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1644 PrepareForBailoutForId(key->id(), NO_REGISTERS); |
1645 } else { | 1645 } else { |
1646 VisitForEffect(value); | 1646 VisitForEffect(value); |
1647 } | 1647 } |
1648 break; | 1648 break; |
1649 } | 1649 } |
1650 __ push(Operand(esp, 0)); // Duplicate receiver. | 1650 __ push(Operand(esp, 0)); // Duplicate receiver. |
1651 VisitForStackValue(key); | 1651 VisitForStackValue(key); |
1652 VisitForStackValue(value); | 1652 VisitForStackValue(value); |
1653 if (property->emit_store()) { | 1653 if (property->emit_store()) { |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 __ bind(&l_next); | 2047 __ bind(&l_next); |
2048 __ mov(ecx, isolate()->factory()->next_string()); // "next" | 2048 __ mov(ecx, isolate()->factory()->next_string()); // "next" |
2049 __ push(ecx); | 2049 __ push(ecx); |
2050 __ push(Operand(esp, 2 * kPointerSize)); // iter | 2050 __ push(Operand(esp, 2 * kPointerSize)); // iter |
2051 __ push(eax); // received | 2051 __ push(eax); // received |
2052 | 2052 |
2053 // result = receiver[f](arg); | 2053 // result = receiver[f](arg); |
2054 __ bind(&l_call); | 2054 __ bind(&l_call); |
2055 __ mov(edx, Operand(esp, kPointerSize)); | 2055 __ mov(edx, Operand(esp, kPointerSize)); |
2056 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2056 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
2057 CallIC(ic, NOT_CONTEXTUAL, TypeFeedbackId::None()); | 2057 CallIC(ic, TypeFeedbackId::None()); |
2058 __ mov(edi, eax); | 2058 __ mov(edi, eax); |
2059 __ mov(Operand(esp, 2 * kPointerSize), edi); | 2059 __ mov(Operand(esp, 2 * kPointerSize), edi); |
2060 CallFunctionStub stub(1, CALL_AS_METHOD); | 2060 CallFunctionStub stub(1, CALL_AS_METHOD); |
2061 __ CallStub(&stub); | 2061 __ CallStub(&stub); |
2062 | 2062 |
2063 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2063 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2064 __ Drop(1); // The function is still on the stack; drop it. | 2064 __ Drop(1); // The function is still on the stack; drop it. |
2065 | 2065 |
2066 // if (!result.done) goto l_try; | 2066 // if (!result.done) goto l_try; |
2067 __ bind(&l_loop); | 2067 __ bind(&l_loop); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2237 Literal* key = prop->key()->AsLiteral(); | 2237 Literal* key = prop->key()->AsLiteral(); |
2238 ASSERT(!key->value()->IsSmi()); | 2238 ASSERT(!key->value()->IsSmi()); |
2239 __ mov(ecx, Immediate(key->value())); | 2239 __ mov(ecx, Immediate(key->value())); |
2240 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2240 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); |
2241 } | 2241 } |
2242 | 2242 |
2243 | 2243 |
2244 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2244 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2245 SetSourcePosition(prop->position()); | 2245 SetSourcePosition(prop->position()); |
2246 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2246 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
2247 CallIC(ic, NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2247 CallIC(ic, prop->PropertyFeedbackId()); |
2248 } | 2248 } |
2249 | 2249 |
2250 | 2250 |
2251 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, | 2251 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
2252 Token::Value op, | 2252 Token::Value op, |
2253 OverwriteMode mode, | 2253 OverwriteMode mode, |
2254 Expression* left, | 2254 Expression* left, |
2255 Expression* right) { | 2255 Expression* right) { |
2256 // Do combined smi check of the operands. Left operand is on the | 2256 // Do combined smi check of the operands. Left operand is on the |
2257 // stack. Right operand is in eax. | 2257 // stack. Right operand is in eax. |
2258 Label smi_case, done, stub_call; | 2258 Label smi_case, done, stub_call; |
2259 __ pop(edx); | 2259 __ pop(edx); |
2260 __ mov(ecx, eax); | 2260 __ mov(ecx, eax); |
2261 __ or_(eax, edx); | 2261 __ or_(eax, edx); |
2262 JumpPatchSite patch_site(masm_); | 2262 JumpPatchSite patch_site(masm_); |
2263 patch_site.EmitJumpIfSmi(eax, &smi_case, Label::kNear); | 2263 patch_site.EmitJumpIfSmi(eax, &smi_case, Label::kNear); |
2264 | 2264 |
2265 __ bind(&stub_call); | 2265 __ bind(&stub_call); |
2266 __ mov(eax, ecx); | 2266 __ mov(eax, ecx); |
2267 BinaryOpICStub stub(op, mode); | 2267 BinaryOpICStub stub(op, mode); |
2268 CallIC(stub.GetCode(isolate()), NOT_CONTEXTUAL, | 2268 CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId()); |
2269 expr->BinaryOperationFeedbackId()); | |
2270 patch_site.EmitPatchInfo(); | 2269 patch_site.EmitPatchInfo(); |
2271 __ jmp(&done, Label::kNear); | 2270 __ jmp(&done, Label::kNear); |
2272 | 2271 |
2273 // Smi case. | 2272 // Smi case. |
2274 __ bind(&smi_case); | 2273 __ bind(&smi_case); |
2275 __ mov(eax, edx); // Copy left operand in case of a stub call. | 2274 __ mov(eax, edx); // Copy left operand in case of a stub call. |
2276 | 2275 |
2277 switch (op) { | 2276 switch (op) { |
2278 case Token::SAR: | 2277 case Token::SAR: |
2279 __ SmiUntag(eax); | 2278 __ SmiUntag(eax); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2344 context()->Plug(eax); | 2343 context()->Plug(eax); |
2345 } | 2344 } |
2346 | 2345 |
2347 | 2346 |
2348 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 2347 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, |
2349 Token::Value op, | 2348 Token::Value op, |
2350 OverwriteMode mode) { | 2349 OverwriteMode mode) { |
2351 __ pop(edx); | 2350 __ pop(edx); |
2352 BinaryOpICStub stub(op, mode); | 2351 BinaryOpICStub stub(op, mode); |
2353 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2352 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2354 CallIC(stub.GetCode(isolate()), NOT_CONTEXTUAL, | 2353 CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId()); |
2355 expr->BinaryOperationFeedbackId()); | |
2356 patch_site.EmitPatchInfo(); | 2354 patch_site.EmitPatchInfo(); |
2357 context()->Plug(eax); | 2355 context()->Plug(eax); |
2358 } | 2356 } |
2359 | 2357 |
2360 | 2358 |
2361 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2359 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
2362 // Invalid left-hand sides are rewritten by the parser to have a 'throw | 2360 // Invalid left-hand sides are rewritten by the parser to have a 'throw |
2363 // ReferenceError' on the left-hand side. | 2361 // ReferenceError' on the left-hand side. |
2364 if (!expr->IsValidLeftHandSide()) { | 2362 if (!expr->IsValidLeftHandSide()) { |
2365 VisitForEffect(expr); | 2363 VisitForEffect(expr); |
(...skipping 17 matching lines...) Expand all Loading... |
2383 EffectContext context(this); | 2381 EffectContext context(this); |
2384 EmitVariableAssignment(var, Token::ASSIGN); | 2382 EmitVariableAssignment(var, Token::ASSIGN); |
2385 break; | 2383 break; |
2386 } | 2384 } |
2387 case NAMED_PROPERTY: { | 2385 case NAMED_PROPERTY: { |
2388 __ push(eax); // Preserve value. | 2386 __ push(eax); // Preserve value. |
2389 VisitForAccumulatorValue(prop->obj()); | 2387 VisitForAccumulatorValue(prop->obj()); |
2390 __ mov(edx, eax); | 2388 __ mov(edx, eax); |
2391 __ pop(eax); // Restore value. | 2389 __ pop(eax); // Restore value. |
2392 __ mov(ecx, prop->key()->AsLiteral()->value()); | 2390 __ mov(ecx, prop->key()->AsLiteral()->value()); |
2393 CallStoreIC(NOT_CONTEXTUAL); | 2391 CallStoreIC(); |
2394 break; | 2392 break; |
2395 } | 2393 } |
2396 case KEYED_PROPERTY: { | 2394 case KEYED_PROPERTY: { |
2397 __ push(eax); // Preserve value. | 2395 __ push(eax); // Preserve value. |
2398 VisitForStackValue(prop->obj()); | 2396 VisitForStackValue(prop->obj()); |
2399 VisitForAccumulatorValue(prop->key()); | 2397 VisitForAccumulatorValue(prop->key()); |
2400 __ mov(ecx, eax); | 2398 __ mov(ecx, eax); |
2401 __ pop(edx); // Receiver. | 2399 __ pop(edx); // Receiver. |
2402 __ pop(eax); // Restore value. | 2400 __ pop(eax); // Restore value. |
2403 Handle<Code> ic = is_classic_mode() | 2401 Handle<Code> ic = is_classic_mode() |
2404 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2402 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
2405 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2403 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2406 CallIC(ic); | 2404 CallIC(ic); |
2407 break; | 2405 break; |
2408 } | 2406 } |
2409 } | 2407 } |
2410 context()->Plug(eax); | 2408 context()->Plug(eax); |
2411 } | 2409 } |
2412 | 2410 |
2413 | 2411 |
2414 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 2412 void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
2415 Token::Value op) { | 2413 Token::Value op) { |
2416 if (var->IsUnallocated()) { | 2414 if (var->IsUnallocated()) { |
2417 // Global var, const, or let. | 2415 // Global var, const, or let. |
2418 __ mov(ecx, var->name()); | 2416 __ mov(ecx, var->name()); |
2419 __ mov(edx, GlobalObjectOperand()); | 2417 __ mov(edx, GlobalObjectOperand()); |
2420 CallStoreIC(CONTEXTUAL); | 2418 CallStoreIC(); |
2421 } else if (op == Token::INIT_CONST) { | 2419 } else if (op == Token::INIT_CONST) { |
2422 // Const initializers need a write barrier. | 2420 // Const initializers need a write barrier. |
2423 ASSERT(!var->IsParameter()); // No const parameters. | 2421 ASSERT(!var->IsParameter()); // No const parameters. |
2424 if (var->IsStackLocal()) { | 2422 if (var->IsStackLocal()) { |
2425 Label skip; | 2423 Label skip; |
2426 __ mov(edx, StackOperand(var)); | 2424 __ mov(edx, StackOperand(var)); |
2427 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2425 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2428 __ j(not_equal, &skip); | 2426 __ j(not_equal, &skip); |
2429 __ mov(StackOperand(var), eax); | 2427 __ mov(StackOperand(var), eax); |
2430 __ bind(&skip); | 2428 __ bind(&skip); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 // esp[0] : receiver | 2502 // esp[0] : receiver |
2505 | 2503 |
2506 Property* prop = expr->target()->AsProperty(); | 2504 Property* prop = expr->target()->AsProperty(); |
2507 ASSERT(prop != NULL); | 2505 ASSERT(prop != NULL); |
2508 ASSERT(prop->key()->AsLiteral() != NULL); | 2506 ASSERT(prop->key()->AsLiteral() != NULL); |
2509 | 2507 |
2510 // Record source code position before IC call. | 2508 // Record source code position before IC call. |
2511 SetSourcePosition(expr->position()); | 2509 SetSourcePosition(expr->position()); |
2512 __ mov(ecx, prop->key()->AsLiteral()->value()); | 2510 __ mov(ecx, prop->key()->AsLiteral()->value()); |
2513 __ pop(edx); | 2511 __ pop(edx); |
2514 CallStoreIC(NOT_CONTEXTUAL, expr->AssignmentFeedbackId()); | 2512 CallStoreIC(expr->AssignmentFeedbackId()); |
2515 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2513 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2516 context()->Plug(eax); | 2514 context()->Plug(eax); |
2517 } | 2515 } |
2518 | 2516 |
2519 | 2517 |
2520 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2518 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
2521 // Assignment to a property, using a keyed store IC. | 2519 // Assignment to a property, using a keyed store IC. |
2522 // eax : value | 2520 // eax : value |
2523 // esp[0] : key | 2521 // esp[0] : key |
2524 // esp[kPointerSize] : receiver | 2522 // esp[kPointerSize] : receiver |
2525 | 2523 |
2526 __ pop(ecx); // Key. | 2524 __ pop(ecx); // Key. |
2527 __ pop(edx); | 2525 __ pop(edx); |
2528 // Record source code position before IC call. | 2526 // Record source code position before IC call. |
2529 SetSourcePosition(expr->position()); | 2527 SetSourcePosition(expr->position()); |
2530 Handle<Code> ic = is_classic_mode() | 2528 Handle<Code> ic = is_classic_mode() |
2531 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2529 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
2532 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2530 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2533 CallIC(ic, NOT_CONTEXTUAL, expr->AssignmentFeedbackId()); | 2531 CallIC(ic, expr->AssignmentFeedbackId()); |
2534 | 2532 |
2535 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2533 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2536 context()->Plug(eax); | 2534 context()->Plug(eax); |
2537 } | 2535 } |
2538 | 2536 |
2539 | 2537 |
2540 void FullCodeGenerator::VisitProperty(Property* expr) { | 2538 void FullCodeGenerator::VisitProperty(Property* expr) { |
2541 Comment cmnt(masm_, "[ Property"); | 2539 Comment cmnt(masm_, "[ Property"); |
2542 Expression* key = expr->key(); | 2540 Expression* key = expr->key(); |
2543 | 2541 |
2544 if (key->IsPropertyName()) { | 2542 if (key->IsPropertyName()) { |
2545 VisitForAccumulatorValue(expr->obj()); | 2543 VisitForAccumulatorValue(expr->obj()); |
2546 __ mov(edx, result_register()); | 2544 __ mov(edx, result_register()); |
2547 EmitNamedPropertyLoad(expr); | 2545 EmitNamedPropertyLoad(expr); |
2548 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2546 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
2549 context()->Plug(eax); | 2547 context()->Plug(eax); |
2550 } else { | 2548 } else { |
2551 VisitForStackValue(expr->obj()); | 2549 VisitForStackValue(expr->obj()); |
2552 VisitForAccumulatorValue(expr->key()); | 2550 VisitForAccumulatorValue(expr->key()); |
2553 __ pop(edx); // Object. | 2551 __ pop(edx); // Object. |
2554 __ mov(ecx, result_register()); // Key. | 2552 __ mov(ecx, result_register()); // Key. |
2555 EmitKeyedPropertyLoad(expr); | 2553 EmitKeyedPropertyLoad(expr); |
2556 context()->Plug(eax); | 2554 context()->Plug(eax); |
2557 } | 2555 } |
2558 } | 2556 } |
2559 | 2557 |
2560 | 2558 |
2561 void FullCodeGenerator::CallIC(Handle<Code> code, | 2559 void FullCodeGenerator::CallIC(Handle<Code> code, |
2562 ContextualMode mode, | |
2563 TypeFeedbackId ast_id) { | 2560 TypeFeedbackId ast_id) { |
2564 ic_total_count_++; | 2561 ic_total_count_++; |
2565 ASSERT(mode != CONTEXTUAL || ast_id.IsNone()); | |
2566 __ call(code, RelocInfo::CODE_TARGET, ast_id); | 2562 __ call(code, RelocInfo::CODE_TARGET, ast_id); |
2567 } | 2563 } |
2568 | 2564 |
2569 | 2565 |
2570 | 2566 |
2571 | 2567 |
2572 // Code common for calls using the IC. | 2568 // Code common for calls using the IC. |
2573 void FullCodeGenerator::EmitCallWithIC(Call* expr) { | 2569 void FullCodeGenerator::EmitCallWithIC(Call* expr) { |
2574 Expression* callee = expr->expression(); | 2570 Expression* callee = expr->expression(); |
2575 ZoneList<Expression*>* args = expr->arguments(); | 2571 ZoneList<Expression*>* args = expr->arguments(); |
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4416 } | 4412 } |
4417 | 4413 |
4418 // Record position before stub call. | 4414 // Record position before stub call. |
4419 SetSourcePosition(expr->position()); | 4415 SetSourcePosition(expr->position()); |
4420 | 4416 |
4421 // Call stub for +1/-1. | 4417 // Call stub for +1/-1. |
4422 __ bind(&stub_call); | 4418 __ bind(&stub_call); |
4423 __ mov(edx, eax); | 4419 __ mov(edx, eax); |
4424 __ mov(eax, Immediate(Smi::FromInt(1))); | 4420 __ mov(eax, Immediate(Smi::FromInt(1))); |
4425 BinaryOpICStub stub(expr->binary_op(), NO_OVERWRITE); | 4421 BinaryOpICStub stub(expr->binary_op(), NO_OVERWRITE); |
4426 CallIC(stub.GetCode(isolate()), | 4422 CallIC(stub.GetCode(isolate()), expr->CountBinOpFeedbackId()); |
4427 NOT_CONTEXTUAL, | |
4428 expr->CountBinOpFeedbackId()); | |
4429 patch_site.EmitPatchInfo(); | 4423 patch_site.EmitPatchInfo(); |
4430 __ bind(&done); | 4424 __ bind(&done); |
4431 | 4425 |
4432 // Store the value returned in eax. | 4426 // Store the value returned in eax. |
4433 switch (assign_type) { | 4427 switch (assign_type) { |
4434 case VARIABLE: | 4428 case VARIABLE: |
4435 if (expr->is_postfix()) { | 4429 if (expr->is_postfix()) { |
4436 // Perform the assignment as if via '='. | 4430 // Perform the assignment as if via '='. |
4437 { EffectContext context(this); | 4431 { EffectContext context(this); |
4438 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4432 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
(...skipping 10 matching lines...) Expand all Loading... |
4449 // Perform the assignment as if via '='. | 4443 // Perform the assignment as if via '='. |
4450 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4444 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
4451 Token::ASSIGN); | 4445 Token::ASSIGN); |
4452 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4446 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4453 context()->Plug(eax); | 4447 context()->Plug(eax); |
4454 } | 4448 } |
4455 break; | 4449 break; |
4456 case NAMED_PROPERTY: { | 4450 case NAMED_PROPERTY: { |
4457 __ mov(ecx, prop->key()->AsLiteral()->value()); | 4451 __ mov(ecx, prop->key()->AsLiteral()->value()); |
4458 __ pop(edx); | 4452 __ pop(edx); |
4459 CallStoreIC(NOT_CONTEXTUAL, expr->CountStoreFeedbackId()); | 4453 CallStoreIC(expr->CountStoreFeedbackId()); |
4460 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4454 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4461 if (expr->is_postfix()) { | 4455 if (expr->is_postfix()) { |
4462 if (!context()->IsEffect()) { | 4456 if (!context()->IsEffect()) { |
4463 context()->PlugTOS(); | 4457 context()->PlugTOS(); |
4464 } | 4458 } |
4465 } else { | 4459 } else { |
4466 context()->Plug(eax); | 4460 context()->Plug(eax); |
4467 } | 4461 } |
4468 break; | 4462 break; |
4469 } | 4463 } |
4470 case KEYED_PROPERTY: { | 4464 case KEYED_PROPERTY: { |
4471 __ pop(ecx); | 4465 __ pop(ecx); |
4472 __ pop(edx); | 4466 __ pop(edx); |
4473 Handle<Code> ic = is_classic_mode() | 4467 Handle<Code> ic = is_classic_mode() |
4474 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 4468 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
4475 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 4469 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
4476 CallIC(ic, NOT_CONTEXTUAL, expr->CountStoreFeedbackId()); | 4470 CallIC(ic, expr->CountStoreFeedbackId()); |
4477 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4471 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
4478 if (expr->is_postfix()) { | 4472 if (expr->is_postfix()) { |
4479 // Result is on the stack | 4473 // Result is on the stack |
4480 if (!context()->IsEffect()) { | 4474 if (!context()->IsEffect()) { |
4481 context()->PlugTOS(); | 4475 context()->PlugTOS(); |
4482 } | 4476 } |
4483 } else { | 4477 } else { |
4484 context()->Plug(eax); | 4478 context()->Plug(eax); |
4485 } | 4479 } |
4486 break; | 4480 break; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4655 __ or_(ecx, eax); | 4649 __ or_(ecx, eax); |
4656 patch_site.EmitJumpIfNotSmi(ecx, &slow_case, Label::kNear); | 4650 patch_site.EmitJumpIfNotSmi(ecx, &slow_case, Label::kNear); |
4657 __ cmp(edx, eax); | 4651 __ cmp(edx, eax); |
4658 Split(cc, if_true, if_false, NULL); | 4652 Split(cc, if_true, if_false, NULL); |
4659 __ bind(&slow_case); | 4653 __ bind(&slow_case); |
4660 } | 4654 } |
4661 | 4655 |
4662 // Record position and call the compare IC. | 4656 // Record position and call the compare IC. |
4663 SetSourcePosition(expr->position()); | 4657 SetSourcePosition(expr->position()); |
4664 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); | 4658 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); |
4665 CallIC(ic, NOT_CONTEXTUAL, expr->CompareOperationFeedbackId()); | 4659 CallIC(ic, expr->CompareOperationFeedbackId()); |
4666 patch_site.EmitPatchInfo(); | 4660 patch_site.EmitPatchInfo(); |
4667 | 4661 |
4668 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4662 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
4669 __ test(eax, eax); | 4663 __ test(eax, eax); |
4670 Split(cc, if_true, if_false, fall_through); | 4664 Split(cc, if_true, if_false, fall_through); |
4671 } | 4665 } |
4672 } | 4666 } |
4673 | 4667 |
4674 // Convert the result of the comparison into one expected for this | 4668 // Convert the result of the comparison into one expected for this |
4675 // expression's context. | 4669 // expression's context. |
(...skipping 15 matching lines...) Expand all Loading... |
4691 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4685 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
4692 | 4686 |
4693 Handle<Object> nil_value = nil == kNullValue | 4687 Handle<Object> nil_value = nil == kNullValue |
4694 ? isolate()->factory()->null_value() | 4688 ? isolate()->factory()->null_value() |
4695 : isolate()->factory()->undefined_value(); | 4689 : isolate()->factory()->undefined_value(); |
4696 if (expr->op() == Token::EQ_STRICT) { | 4690 if (expr->op() == Token::EQ_STRICT) { |
4697 __ cmp(eax, nil_value); | 4691 __ cmp(eax, nil_value); |
4698 Split(equal, if_true, if_false, fall_through); | 4692 Split(equal, if_true, if_false, fall_through); |
4699 } else { | 4693 } else { |
4700 Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil); | 4694 Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil); |
4701 CallIC(ic, NOT_CONTEXTUAL, expr->CompareOperationFeedbackId()); | 4695 CallIC(ic, expr->CompareOperationFeedbackId()); |
4702 __ test(eax, eax); | 4696 __ test(eax, eax); |
4703 Split(not_zero, if_true, if_false, fall_through); | 4697 Split(not_zero, if_true, if_false, fall_through); |
4704 } | 4698 } |
4705 context()->Plug(if_true, if_false); | 4699 context()->Plug(if_true, if_false); |
4706 } | 4700 } |
4707 | 4701 |
4708 | 4702 |
4709 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 4703 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
4710 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 4704 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
4711 context()->Plug(eax); | 4705 context()->Plug(eax); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4919 | 4913 |
4920 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4914 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4921 Assembler::target_address_at(call_target_address)); | 4915 Assembler::target_address_at(call_target_address)); |
4922 return OSR_AFTER_STACK_CHECK; | 4916 return OSR_AFTER_STACK_CHECK; |
4923 } | 4917 } |
4924 | 4918 |
4925 | 4919 |
4926 } } // namespace v8::internal | 4920 } } // namespace v8::internal |
4927 | 4921 |
4928 #endif // V8_TARGET_ARCH_IA32 | 4922 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |