| 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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 if (false_label_ != fall_through_) __ jmp(false_label_); | 634 if (false_label_ != fall_through_) __ jmp(false_label_); |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 | 637 |
| 638 | 638 |
| 639 void FullCodeGenerator::DoTest(Expression* condition, | 639 void FullCodeGenerator::DoTest(Expression* condition, |
| 640 Label* if_true, | 640 Label* if_true, |
| 641 Label* if_false, | 641 Label* if_false, |
| 642 Label* fall_through) { | 642 Label* fall_through) { |
| 643 Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate()); | 643 Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate()); |
| 644 CallIC(ic, NOT_CONTEXTUAL, condition->test_id()); | 644 CallIC(ic, condition->test_id()); |
| 645 __ testq(result_register(), result_register()); | 645 __ testq(result_register(), result_register()); |
| 646 // The stub returns nonzero for true. | 646 // The stub returns nonzero for true. |
| 647 Split(not_zero, if_true, if_false, fall_through); | 647 Split(not_zero, if_true, if_false, fall_through); |
| 648 } | 648 } |
| 649 | 649 |
| 650 | 650 |
| 651 void FullCodeGenerator::Split(Condition cc, | 651 void FullCodeGenerator::Split(Condition cc, |
| 652 Label* if_true, | 652 Label* if_true, |
| 653 Label* if_false, | 653 Label* if_false, |
| 654 Label* fall_through) { | 654 Label* fall_through) { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 __ cmpq(rdx, rax); | 987 __ cmpq(rdx, rax); |
| 988 __ j(not_equal, &next_test); | 988 __ j(not_equal, &next_test); |
| 989 __ Drop(1); // Switch value is no longer needed. | 989 __ Drop(1); // Switch value is no longer needed. |
| 990 __ jmp(clause->body_target()); | 990 __ jmp(clause->body_target()); |
| 991 __ bind(&slow_case); | 991 __ bind(&slow_case); |
| 992 } | 992 } |
| 993 | 993 |
| 994 // Record position before stub call for type feedback. | 994 // Record position before stub call for type feedback. |
| 995 SetSourcePosition(clause->position()); | 995 SetSourcePosition(clause->position()); |
| 996 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); | 996 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); |
| 997 CallIC(ic, NOT_CONTEXTUAL, clause->CompareId()); | 997 CallIC(ic, clause->CompareId()); |
| 998 patch_site.EmitPatchInfo(); | 998 patch_site.EmitPatchInfo(); |
| 999 | 999 |
| 1000 Label skip; | 1000 Label skip; |
| 1001 __ jmp(&skip, Label::kNear); | 1001 __ jmp(&skip, Label::kNear); |
| 1002 PrepareForBailout(clause, TOS_REG); | 1002 PrepareForBailout(clause, TOS_REG); |
| 1003 __ CompareRoot(rax, Heap::kTrueValueRootIndex); | 1003 __ CompareRoot(rax, Heap::kTrueValueRootIndex); |
| 1004 __ j(not_equal, &next_test); | 1004 __ j(not_equal, &next_test); |
| 1005 __ Drop(1); | 1005 __ Drop(1); |
| 1006 __ jmp(clause->body_target()); | 1006 __ jmp(clause->body_target()); |
| 1007 __ bind(&skip); | 1007 __ bind(&skip); |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 UNREACHABLE(); | 1656 UNREACHABLE(); |
| 1657 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1657 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1658 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); | 1658 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
| 1659 // Fall through. | 1659 // Fall through. |
| 1660 case ObjectLiteral::Property::COMPUTED: | 1660 case ObjectLiteral::Property::COMPUTED: |
| 1661 if (key->value()->IsInternalizedString()) { | 1661 if (key->value()->IsInternalizedString()) { |
| 1662 if (property->emit_store()) { | 1662 if (property->emit_store()) { |
| 1663 VisitForAccumulatorValue(value); | 1663 VisitForAccumulatorValue(value); |
| 1664 __ Move(rcx, key->value()); | 1664 __ Move(rcx, key->value()); |
| 1665 __ movp(rdx, Operand(rsp, 0)); | 1665 __ movp(rdx, Operand(rsp, 0)); |
| 1666 CallStoreIC(NOT_CONTEXTUAL, key->LiteralFeedbackId()); | 1666 CallStoreIC(key->LiteralFeedbackId()); |
| 1667 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1667 PrepareForBailoutForId(key->id(), NO_REGISTERS); |
| 1668 } else { | 1668 } else { |
| 1669 VisitForEffect(value); | 1669 VisitForEffect(value); |
| 1670 } | 1670 } |
| 1671 break; | 1671 break; |
| 1672 } | 1672 } |
| 1673 __ push(Operand(rsp, 0)); // Duplicate receiver. | 1673 __ push(Operand(rsp, 0)); // Duplicate receiver. |
| 1674 VisitForStackValue(key); | 1674 VisitForStackValue(key); |
| 1675 VisitForStackValue(value); | 1675 VisitForStackValue(value); |
| 1676 if (property->emit_store()) { | 1676 if (property->emit_store()) { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2071 __ LoadRoot(rcx, Heap::knext_stringRootIndex); // "next" | 2071 __ LoadRoot(rcx, Heap::knext_stringRootIndex); // "next" |
| 2072 __ push(rcx); | 2072 __ push(rcx); |
| 2073 __ push(Operand(rsp, 2 * kPointerSize)); // iter | 2073 __ push(Operand(rsp, 2 * kPointerSize)); // iter |
| 2074 __ push(rax); // received | 2074 __ push(rax); // received |
| 2075 | 2075 |
| 2076 // result = receiver[f](arg); | 2076 // result = receiver[f](arg); |
| 2077 __ bind(&l_call); | 2077 __ bind(&l_call); |
| 2078 __ movp(rdx, Operand(rsp, kPointerSize)); | 2078 __ movp(rdx, Operand(rsp, kPointerSize)); |
| 2079 __ movp(rax, Operand(rsp, 2 * kPointerSize)); | 2079 __ movp(rax, Operand(rsp, 2 * kPointerSize)); |
| 2080 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2080 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
| 2081 CallIC(ic, NOT_CONTEXTUAL, TypeFeedbackId::None()); | 2081 CallIC(ic, TypeFeedbackId::None()); |
| 2082 __ movp(rdi, rax); | 2082 __ movp(rdi, rax); |
| 2083 __ movp(Operand(rsp, 2 * kPointerSize), rdi); | 2083 __ movp(Operand(rsp, 2 * kPointerSize), rdi); |
| 2084 CallFunctionStub stub(1, CALL_AS_METHOD); | 2084 CallFunctionStub stub(1, CALL_AS_METHOD); |
| 2085 __ CallStub(&stub); | 2085 __ CallStub(&stub); |
| 2086 | 2086 |
| 2087 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2087 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2088 __ Drop(1); // The function is still on the stack; drop it. | 2088 __ Drop(1); // The function is still on the stack; drop it. |
| 2089 | 2089 |
| 2090 // if (!result.done) goto l_try; | 2090 // if (!result.done) goto l_try; |
| 2091 __ bind(&l_loop); | 2091 __ bind(&l_loop); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 SetSourcePosition(prop->position()); | 2262 SetSourcePosition(prop->position()); |
| 2263 Literal* key = prop->key()->AsLiteral(); | 2263 Literal* key = prop->key()->AsLiteral(); |
| 2264 __ Move(rcx, key->value()); | 2264 __ Move(rcx, key->value()); |
| 2265 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2265 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); |
| 2266 } | 2266 } |
| 2267 | 2267 |
| 2268 | 2268 |
| 2269 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2269 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
| 2270 SetSourcePosition(prop->position()); | 2270 SetSourcePosition(prop->position()); |
| 2271 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2271 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
| 2272 CallIC(ic, NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2272 CallIC(ic, prop->PropertyFeedbackId()); |
| 2273 } | 2273 } |
| 2274 | 2274 |
| 2275 | 2275 |
| 2276 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, | 2276 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
| 2277 Token::Value op, | 2277 Token::Value op, |
| 2278 OverwriteMode mode, | 2278 OverwriteMode mode, |
| 2279 Expression* left, | 2279 Expression* left, |
| 2280 Expression* right) { | 2280 Expression* right) { |
| 2281 // Do combined smi check of the operands. Left operand is on the | 2281 // Do combined smi check of the operands. Left operand is on the |
| 2282 // stack (popped into rdx). Right operand is in rax but moved into | 2282 // stack (popped into rdx). Right operand is in rax but moved into |
| 2283 // rcx to make the shifts easier. | 2283 // rcx to make the shifts easier. |
| 2284 Label done, stub_call, smi_case; | 2284 Label done, stub_call, smi_case; |
| 2285 __ pop(rdx); | 2285 __ pop(rdx); |
| 2286 __ movp(rcx, rax); | 2286 __ movp(rcx, rax); |
| 2287 __ or_(rax, rdx); | 2287 __ or_(rax, rdx); |
| 2288 JumpPatchSite patch_site(masm_); | 2288 JumpPatchSite patch_site(masm_); |
| 2289 patch_site.EmitJumpIfSmi(rax, &smi_case, Label::kNear); | 2289 patch_site.EmitJumpIfSmi(rax, &smi_case, Label::kNear); |
| 2290 | 2290 |
| 2291 __ bind(&stub_call); | 2291 __ bind(&stub_call); |
| 2292 __ movp(rax, rcx); | 2292 __ movp(rax, rcx); |
| 2293 BinaryOpICStub stub(op, mode); | 2293 BinaryOpICStub stub(op, mode); |
| 2294 CallIC(stub.GetCode(isolate()), NOT_CONTEXTUAL, | 2294 CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId()); |
| 2295 expr->BinaryOperationFeedbackId()); | |
| 2296 patch_site.EmitPatchInfo(); | 2295 patch_site.EmitPatchInfo(); |
| 2297 __ jmp(&done, Label::kNear); | 2296 __ jmp(&done, Label::kNear); |
| 2298 | 2297 |
| 2299 __ bind(&smi_case); | 2298 __ bind(&smi_case); |
| 2300 switch (op) { | 2299 switch (op) { |
| 2301 case Token::SAR: | 2300 case Token::SAR: |
| 2302 __ SmiShiftArithmeticRight(rax, rdx, rcx); | 2301 __ SmiShiftArithmeticRight(rax, rdx, rcx); |
| 2303 break; | 2302 break; |
| 2304 case Token::SHL: | 2303 case Token::SHL: |
| 2305 __ SmiShiftLeft(rax, rdx, rcx); | 2304 __ SmiShiftLeft(rax, rdx, rcx); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2334 context()->Plug(rax); | 2333 context()->Plug(rax); |
| 2335 } | 2334 } |
| 2336 | 2335 |
| 2337 | 2336 |
| 2338 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 2337 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, |
| 2339 Token::Value op, | 2338 Token::Value op, |
| 2340 OverwriteMode mode) { | 2339 OverwriteMode mode) { |
| 2341 __ pop(rdx); | 2340 __ pop(rdx); |
| 2342 BinaryOpICStub stub(op, mode); | 2341 BinaryOpICStub stub(op, mode); |
| 2343 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2342 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
| 2344 CallIC(stub.GetCode(isolate()), NOT_CONTEXTUAL, | 2343 CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId()); |
| 2345 expr->BinaryOperationFeedbackId()); | |
| 2346 patch_site.EmitPatchInfo(); | 2344 patch_site.EmitPatchInfo(); |
| 2347 context()->Plug(rax); | 2345 context()->Plug(rax); |
| 2348 } | 2346 } |
| 2349 | 2347 |
| 2350 | 2348 |
| 2351 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2349 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
| 2352 // Invalid left-hand sides are rewritten by the parser to have a 'throw | 2350 // Invalid left-hand sides are rewritten by the parser to have a 'throw |
| 2353 // ReferenceError' on the left-hand side. | 2351 // ReferenceError' on the left-hand side. |
| 2354 if (!expr->IsValidLeftHandSide()) { | 2352 if (!expr->IsValidLeftHandSide()) { |
| 2355 VisitForEffect(expr); | 2353 VisitForEffect(expr); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2373 EffectContext context(this); | 2371 EffectContext context(this); |
| 2374 EmitVariableAssignment(var, Token::ASSIGN); | 2372 EmitVariableAssignment(var, Token::ASSIGN); |
| 2375 break; | 2373 break; |
| 2376 } | 2374 } |
| 2377 case NAMED_PROPERTY: { | 2375 case NAMED_PROPERTY: { |
| 2378 __ push(rax); // Preserve value. | 2376 __ push(rax); // Preserve value. |
| 2379 VisitForAccumulatorValue(prop->obj()); | 2377 VisitForAccumulatorValue(prop->obj()); |
| 2380 __ movp(rdx, rax); | 2378 __ movp(rdx, rax); |
| 2381 __ pop(rax); // Restore value. | 2379 __ pop(rax); // Restore value. |
| 2382 __ Move(rcx, prop->key()->AsLiteral()->value()); | 2380 __ Move(rcx, prop->key()->AsLiteral()->value()); |
| 2383 CallStoreIC(NOT_CONTEXTUAL); | 2381 CallStoreIC(); |
| 2384 break; | 2382 break; |
| 2385 } | 2383 } |
| 2386 case KEYED_PROPERTY: { | 2384 case KEYED_PROPERTY: { |
| 2387 __ push(rax); // Preserve value. | 2385 __ push(rax); // Preserve value. |
| 2388 VisitForStackValue(prop->obj()); | 2386 VisitForStackValue(prop->obj()); |
| 2389 VisitForAccumulatorValue(prop->key()); | 2387 VisitForAccumulatorValue(prop->key()); |
| 2390 __ movp(rcx, rax); | 2388 __ movp(rcx, rax); |
| 2391 __ pop(rdx); | 2389 __ pop(rdx); |
| 2392 __ pop(rax); // Restore value. | 2390 __ pop(rax); // Restore value. |
| 2393 Handle<Code> ic = is_classic_mode() | 2391 Handle<Code> ic = is_classic_mode() |
| 2394 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2392 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 2395 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2393 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
| 2396 CallIC(ic); | 2394 CallIC(ic); |
| 2397 break; | 2395 break; |
| 2398 } | 2396 } |
| 2399 } | 2397 } |
| 2400 context()->Plug(rax); | 2398 context()->Plug(rax); |
| 2401 } | 2399 } |
| 2402 | 2400 |
| 2403 | 2401 |
| 2404 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 2402 void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
| 2405 Token::Value op) { | 2403 Token::Value op) { |
| 2406 if (var->IsUnallocated()) { | 2404 if (var->IsUnallocated()) { |
| 2407 // Global var, const, or let. | 2405 // Global var, const, or let. |
| 2408 __ Move(rcx, var->name()); | 2406 __ Move(rcx, var->name()); |
| 2409 __ movp(rdx, GlobalObjectOperand()); | 2407 __ movp(rdx, GlobalObjectOperand()); |
| 2410 CallStoreIC(CONTEXTUAL); | 2408 CallStoreIC(); |
| 2411 } else if (op == Token::INIT_CONST) { | 2409 } else if (op == Token::INIT_CONST) { |
| 2412 // Const initializers need a write barrier. | 2410 // Const initializers need a write barrier. |
| 2413 ASSERT(!var->IsParameter()); // No const parameters. | 2411 ASSERT(!var->IsParameter()); // No const parameters. |
| 2414 if (var->IsStackLocal()) { | 2412 if (var->IsStackLocal()) { |
| 2415 Label skip; | 2413 Label skip; |
| 2416 __ movp(rdx, StackOperand(var)); | 2414 __ movp(rdx, StackOperand(var)); |
| 2417 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2415 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); |
| 2418 __ j(not_equal, &skip); | 2416 __ j(not_equal, &skip); |
| 2419 __ movp(StackOperand(var), rax); | 2417 __ movp(StackOperand(var), rax); |
| 2420 __ bind(&skip); | 2418 __ bind(&skip); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2489 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
| 2492 // Assignment to a property, using a named store IC. | 2490 // Assignment to a property, using a named store IC. |
| 2493 Property* prop = expr->target()->AsProperty(); | 2491 Property* prop = expr->target()->AsProperty(); |
| 2494 ASSERT(prop != NULL); | 2492 ASSERT(prop != NULL); |
| 2495 ASSERT(prop->key()->AsLiteral() != NULL); | 2493 ASSERT(prop->key()->AsLiteral() != NULL); |
| 2496 | 2494 |
| 2497 // Record source code position before IC call. | 2495 // Record source code position before IC call. |
| 2498 SetSourcePosition(expr->position()); | 2496 SetSourcePosition(expr->position()); |
| 2499 __ Move(rcx, prop->key()->AsLiteral()->value()); | 2497 __ Move(rcx, prop->key()->AsLiteral()->value()); |
| 2500 __ pop(rdx); | 2498 __ pop(rdx); |
| 2501 CallStoreIC(NOT_CONTEXTUAL, expr->AssignmentFeedbackId()); | 2499 CallStoreIC(expr->AssignmentFeedbackId()); |
| 2502 | 2500 |
| 2503 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2501 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 2504 context()->Plug(rax); | 2502 context()->Plug(rax); |
| 2505 } | 2503 } |
| 2506 | 2504 |
| 2507 | 2505 |
| 2508 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2506 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
| 2509 // Assignment to a property, using a keyed store IC. | 2507 // Assignment to a property, using a keyed store IC. |
| 2510 | 2508 |
| 2511 __ pop(rcx); | 2509 __ pop(rcx); |
| 2512 __ pop(rdx); | 2510 __ pop(rdx); |
| 2513 // Record source code position before IC call. | 2511 // Record source code position before IC call. |
| 2514 SetSourcePosition(expr->position()); | 2512 SetSourcePosition(expr->position()); |
| 2515 Handle<Code> ic = is_classic_mode() | 2513 Handle<Code> ic = is_classic_mode() |
| 2516 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2514 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 2517 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2515 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
| 2518 CallIC(ic, NOT_CONTEXTUAL, expr->AssignmentFeedbackId()); | 2516 CallIC(ic, expr->AssignmentFeedbackId()); |
| 2519 | 2517 |
| 2520 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2518 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 2521 context()->Plug(rax); | 2519 context()->Plug(rax); |
| 2522 } | 2520 } |
| 2523 | 2521 |
| 2524 | 2522 |
| 2525 void FullCodeGenerator::VisitProperty(Property* expr) { | 2523 void FullCodeGenerator::VisitProperty(Property* expr) { |
| 2526 Comment cmnt(masm_, "[ Property"); | 2524 Comment cmnt(masm_, "[ Property"); |
| 2527 Expression* key = expr->key(); | 2525 Expression* key = expr->key(); |
| 2528 | 2526 |
| 2529 if (key->IsPropertyName()) { | 2527 if (key->IsPropertyName()) { |
| 2530 VisitForAccumulatorValue(expr->obj()); | 2528 VisitForAccumulatorValue(expr->obj()); |
| 2531 EmitNamedPropertyLoad(expr); | 2529 EmitNamedPropertyLoad(expr); |
| 2532 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2530 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
| 2533 context()->Plug(rax); | 2531 context()->Plug(rax); |
| 2534 } else { | 2532 } else { |
| 2535 VisitForStackValue(expr->obj()); | 2533 VisitForStackValue(expr->obj()); |
| 2536 VisitForAccumulatorValue(expr->key()); | 2534 VisitForAccumulatorValue(expr->key()); |
| 2537 __ pop(rdx); | 2535 __ pop(rdx); |
| 2538 EmitKeyedPropertyLoad(expr); | 2536 EmitKeyedPropertyLoad(expr); |
| 2539 context()->Plug(rax); | 2537 context()->Plug(rax); |
| 2540 } | 2538 } |
| 2541 } | 2539 } |
| 2542 | 2540 |
| 2543 | 2541 |
| 2544 void FullCodeGenerator::CallIC(Handle<Code> code, | 2542 void FullCodeGenerator::CallIC(Handle<Code> code, |
| 2545 ContextualMode mode, | |
| 2546 TypeFeedbackId ast_id) { | 2543 TypeFeedbackId ast_id) { |
| 2547 ic_total_count_++; | 2544 ic_total_count_++; |
| 2548 ASSERT(mode != CONTEXTUAL || ast_id.IsNone()); | |
| 2549 __ call(code, RelocInfo::CODE_TARGET, ast_id); | 2545 __ call(code, RelocInfo::CODE_TARGET, ast_id); |
| 2550 } | 2546 } |
| 2551 | 2547 |
| 2552 | 2548 |
| 2553 // Code common for calls using the IC. | 2549 // Code common for calls using the IC. |
| 2554 void FullCodeGenerator::EmitCallWithIC(Call* expr) { | 2550 void FullCodeGenerator::EmitCallWithIC(Call* expr) { |
| 2555 Expression* callee = expr->expression(); | 2551 Expression* callee = expr->expression(); |
| 2556 ZoneList<Expression*>* args = expr->arguments(); | 2552 ZoneList<Expression*>* args = expr->arguments(); |
| 2557 int arg_count = args->length(); | 2553 int arg_count = args->length(); |
| 2558 | 2554 |
| (...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4407 } | 4403 } |
| 4408 | 4404 |
| 4409 // Record position before stub call. | 4405 // Record position before stub call. |
| 4410 SetSourcePosition(expr->position()); | 4406 SetSourcePosition(expr->position()); |
| 4411 | 4407 |
| 4412 // Call stub for +1/-1. | 4408 // Call stub for +1/-1. |
| 4413 __ bind(&stub_call); | 4409 __ bind(&stub_call); |
| 4414 __ movp(rdx, rax); | 4410 __ movp(rdx, rax); |
| 4415 __ Move(rax, Smi::FromInt(1)); | 4411 __ Move(rax, Smi::FromInt(1)); |
| 4416 BinaryOpICStub stub(expr->binary_op(), NO_OVERWRITE); | 4412 BinaryOpICStub stub(expr->binary_op(), NO_OVERWRITE); |
| 4417 CallIC(stub.GetCode(isolate()), | 4413 CallIC(stub.GetCode(isolate()), expr->CountBinOpFeedbackId()); |
| 4418 NOT_CONTEXTUAL, | |
| 4419 expr->CountBinOpFeedbackId()); | |
| 4420 patch_site.EmitPatchInfo(); | 4414 patch_site.EmitPatchInfo(); |
| 4421 __ bind(&done); | 4415 __ bind(&done); |
| 4422 | 4416 |
| 4423 // Store the value returned in rax. | 4417 // Store the value returned in rax. |
| 4424 switch (assign_type) { | 4418 switch (assign_type) { |
| 4425 case VARIABLE: | 4419 case VARIABLE: |
| 4426 if (expr->is_postfix()) { | 4420 if (expr->is_postfix()) { |
| 4427 // Perform the assignment as if via '='. | 4421 // Perform the assignment as if via '='. |
| 4428 { EffectContext context(this); | 4422 { EffectContext context(this); |
| 4429 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4423 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4440 // Perform the assignment as if via '='. | 4434 // Perform the assignment as if via '='. |
| 4441 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 4435 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
| 4442 Token::ASSIGN); | 4436 Token::ASSIGN); |
| 4443 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4437 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 4444 context()->Plug(rax); | 4438 context()->Plug(rax); |
| 4445 } | 4439 } |
| 4446 break; | 4440 break; |
| 4447 case NAMED_PROPERTY: { | 4441 case NAMED_PROPERTY: { |
| 4448 __ Move(rcx, prop->key()->AsLiteral()->value()); | 4442 __ Move(rcx, prop->key()->AsLiteral()->value()); |
| 4449 __ pop(rdx); | 4443 __ pop(rdx); |
| 4450 CallStoreIC(NOT_CONTEXTUAL, expr->CountStoreFeedbackId()); | 4444 CallStoreIC(expr->CountStoreFeedbackId()); |
| 4451 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4445 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 4452 if (expr->is_postfix()) { | 4446 if (expr->is_postfix()) { |
| 4453 if (!context()->IsEffect()) { | 4447 if (!context()->IsEffect()) { |
| 4454 context()->PlugTOS(); | 4448 context()->PlugTOS(); |
| 4455 } | 4449 } |
| 4456 } else { | 4450 } else { |
| 4457 context()->Plug(rax); | 4451 context()->Plug(rax); |
| 4458 } | 4452 } |
| 4459 break; | 4453 break; |
| 4460 } | 4454 } |
| 4461 case KEYED_PROPERTY: { | 4455 case KEYED_PROPERTY: { |
| 4462 __ pop(rcx); | 4456 __ pop(rcx); |
| 4463 __ pop(rdx); | 4457 __ pop(rdx); |
| 4464 Handle<Code> ic = is_classic_mode() | 4458 Handle<Code> ic = is_classic_mode() |
| 4465 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 4459 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 4466 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 4460 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
| 4467 CallIC(ic, NOT_CONTEXTUAL, expr->CountStoreFeedbackId()); | 4461 CallIC(ic, expr->CountStoreFeedbackId()); |
| 4468 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 4462 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 4469 if (expr->is_postfix()) { | 4463 if (expr->is_postfix()) { |
| 4470 if (!context()->IsEffect()) { | 4464 if (!context()->IsEffect()) { |
| 4471 context()->PlugTOS(); | 4465 context()->PlugTOS(); |
| 4472 } | 4466 } |
| 4473 } else { | 4467 } else { |
| 4474 context()->Plug(rax); | 4468 context()->Plug(rax); |
| 4475 } | 4469 } |
| 4476 break; | 4470 break; |
| 4477 } | 4471 } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4645 __ or_(rcx, rax); | 4639 __ or_(rcx, rax); |
| 4646 patch_site.EmitJumpIfNotSmi(rcx, &slow_case, Label::kNear); | 4640 patch_site.EmitJumpIfNotSmi(rcx, &slow_case, Label::kNear); |
| 4647 __ cmpq(rdx, rax); | 4641 __ cmpq(rdx, rax); |
| 4648 Split(cc, if_true, if_false, NULL); | 4642 Split(cc, if_true, if_false, NULL); |
| 4649 __ bind(&slow_case); | 4643 __ bind(&slow_case); |
| 4650 } | 4644 } |
| 4651 | 4645 |
| 4652 // Record position and call the compare IC. | 4646 // Record position and call the compare IC. |
| 4653 SetSourcePosition(expr->position()); | 4647 SetSourcePosition(expr->position()); |
| 4654 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); | 4648 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); |
| 4655 CallIC(ic, NOT_CONTEXTUAL, expr->CompareOperationFeedbackId()); | 4649 CallIC(ic, expr->CompareOperationFeedbackId()); |
| 4656 patch_site.EmitPatchInfo(); | 4650 patch_site.EmitPatchInfo(); |
| 4657 | 4651 |
| 4658 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4652 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
| 4659 __ testq(rax, rax); | 4653 __ testq(rax, rax); |
| 4660 Split(cc, if_true, if_false, fall_through); | 4654 Split(cc, if_true, if_false, fall_through); |
| 4661 } | 4655 } |
| 4662 } | 4656 } |
| 4663 | 4657 |
| 4664 // Convert the result of the comparison into one expected for this | 4658 // Convert the result of the comparison into one expected for this |
| 4665 // expression's context. | 4659 // expression's context. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4680 VisitForAccumulatorValue(sub_expr); | 4674 VisitForAccumulatorValue(sub_expr); |
| 4681 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 4675 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
| 4682 if (expr->op() == Token::EQ_STRICT) { | 4676 if (expr->op() == Token::EQ_STRICT) { |
| 4683 Heap::RootListIndex nil_value = nil == kNullValue ? | 4677 Heap::RootListIndex nil_value = nil == kNullValue ? |
| 4684 Heap::kNullValueRootIndex : | 4678 Heap::kNullValueRootIndex : |
| 4685 Heap::kUndefinedValueRootIndex; | 4679 Heap::kUndefinedValueRootIndex; |
| 4686 __ CompareRoot(rax, nil_value); | 4680 __ CompareRoot(rax, nil_value); |
| 4687 Split(equal, if_true, if_false, fall_through); | 4681 Split(equal, if_true, if_false, fall_through); |
| 4688 } else { | 4682 } else { |
| 4689 Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil); | 4683 Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil); |
| 4690 CallIC(ic, NOT_CONTEXTUAL, expr->CompareOperationFeedbackId()); | 4684 CallIC(ic, expr->CompareOperationFeedbackId()); |
| 4691 __ testq(rax, rax); | 4685 __ testq(rax, rax); |
| 4692 Split(not_zero, if_true, if_false, fall_through); | 4686 Split(not_zero, if_true, if_false, fall_through); |
| 4693 } | 4687 } |
| 4694 context()->Plug(if_true, if_false); | 4688 context()->Plug(if_true, if_false); |
| 4695 } | 4689 } |
| 4696 | 4690 |
| 4697 | 4691 |
| 4698 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 4692 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
| 4699 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 4693 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 4700 context()->Plug(rax); | 4694 context()->Plug(rax); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4912 | 4906 |
| 4913 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4907 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4914 Assembler::target_address_at(call_target_address)); | 4908 Assembler::target_address_at(call_target_address)); |
| 4915 return OSR_AFTER_STACK_CHECK; | 4909 return OSR_AFTER_STACK_CHECK; |
| 4916 } | 4910 } |
| 4917 | 4911 |
| 4918 | 4912 |
| 4919 } } // namespace v8::internal | 4913 } } // namespace v8::internal |
| 4920 | 4914 |
| 4921 #endif // V8_TARGET_ARCH_X64 | 4915 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |