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_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 EmitKeyedPropertyLoad(property); | 1990 EmitKeyedPropertyLoad(property); |
1991 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1991 PrepareForBailoutForId(property->LoadId(), TOS_REG); |
1992 break; | 1992 break; |
1993 } | 1993 } |
1994 } | 1994 } |
1995 | 1995 |
1996 Token::Value op = expr->binary_op(); | 1996 Token::Value op = expr->binary_op(); |
1997 __ Push(rax); // Left operand goes on the stack. | 1997 __ Push(rax); // Left operand goes on the stack. |
1998 VisitForAccumulatorValue(expr->value()); | 1998 VisitForAccumulatorValue(expr->value()); |
1999 | 1999 |
2000 OverwriteMode mode = expr->value()->ResultOverwriteAllowed() | |
2001 ? OVERWRITE_RIGHT | |
2002 : NO_OVERWRITE; | |
2003 SetSourcePosition(expr->position() + 1); | 2000 SetSourcePosition(expr->position() + 1); |
2004 AccumulatorValueContext context(this); | 2001 AccumulatorValueContext context(this); |
2005 if (ShouldInlineSmiCase(op)) { | 2002 if (ShouldInlineSmiCase(op)) { |
2006 EmitInlineSmiBinaryOp(expr->binary_operation(), | 2003 EmitInlineSmiBinaryOp(expr->binary_operation(), |
2007 op, | 2004 op, |
2008 mode, | |
2009 expr->target(), | 2005 expr->target(), |
2010 expr->value()); | 2006 expr->value()); |
2011 } else { | 2007 } else { |
2012 EmitBinaryOp(expr->binary_operation(), op, mode); | 2008 EmitBinaryOp(expr->binary_operation(), op); |
2013 } | 2009 } |
2014 // Deoptimization point in case the binary operation may have side effects. | 2010 // Deoptimization point in case the binary operation may have side effects. |
2015 PrepareForBailout(expr->binary_operation(), TOS_REG); | 2011 PrepareForBailout(expr->binary_operation(), TOS_REG); |
2016 } else { | 2012 } else { |
2017 VisitForAccumulatorValue(expr->value()); | 2013 VisitForAccumulatorValue(expr->value()); |
2018 } | 2014 } |
2019 | 2015 |
2020 // Record source position before possible IC call. | 2016 // Record source position before possible IC call. |
2021 SetSourcePosition(expr->position()); | 2017 SetSourcePosition(expr->position()); |
2022 | 2018 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2382 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | 2378 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
2383 // Stack: receiver, home_object, key. | 2379 // Stack: receiver, home_object, key. |
2384 SetSourcePosition(prop->position()); | 2380 SetSourcePosition(prop->position()); |
2385 | 2381 |
2386 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); | 2382 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
2387 } | 2383 } |
2388 | 2384 |
2389 | 2385 |
2390 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, | 2386 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
2391 Token::Value op, | 2387 Token::Value op, |
2392 OverwriteMode mode, | |
2393 Expression* left, | 2388 Expression* left, |
2394 Expression* right) { | 2389 Expression* right) { |
2395 // Do combined smi check of the operands. Left operand is on the | 2390 // Do combined smi check of the operands. Left operand is on the |
2396 // stack (popped into rdx). Right operand is in rax but moved into | 2391 // stack (popped into rdx). Right operand is in rax but moved into |
2397 // rcx to make the shifts easier. | 2392 // rcx to make the shifts easier. |
2398 Label done, stub_call, smi_case; | 2393 Label done, stub_call, smi_case; |
2399 __ Pop(rdx); | 2394 __ Pop(rdx); |
2400 __ movp(rcx, rax); | 2395 __ movp(rcx, rax); |
2401 __ orp(rax, rdx); | 2396 __ orp(rax, rdx); |
2402 JumpPatchSite patch_site(masm_); | 2397 JumpPatchSite patch_site(masm_); |
2403 patch_site.EmitJumpIfSmi(rax, &smi_case, Label::kNear); | 2398 patch_site.EmitJumpIfSmi(rax, &smi_case, Label::kNear); |
2404 | 2399 |
2405 __ bind(&stub_call); | 2400 __ bind(&stub_call); |
2406 __ movp(rax, rcx); | 2401 __ movp(rax, rcx); |
2407 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); | 2402 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); |
2408 CallIC(code, expr->BinaryOperationFeedbackId()); | 2403 CallIC(code, expr->BinaryOperationFeedbackId()); |
2409 patch_site.EmitPatchInfo(); | 2404 patch_site.EmitPatchInfo(); |
2410 __ jmp(&done, Label::kNear); | 2405 __ jmp(&done, Label::kNear); |
2411 | 2406 |
2412 __ bind(&smi_case); | 2407 __ bind(&smi_case); |
2413 switch (op) { | 2408 switch (op) { |
2414 case Token::SAR: | 2409 case Token::SAR: |
2415 __ SmiShiftArithmeticRight(rax, rdx, rcx); | 2410 __ SmiShiftArithmeticRight(rax, rdx, rcx); |
2416 break; | 2411 break; |
2417 case Token::SHL: | 2412 case Token::SHL: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2497 } | 2492 } |
2498 | 2493 |
2499 // prototype | 2494 // prototype |
2500 __ CallRuntime(Runtime::kToFastProperties, 1); | 2495 __ CallRuntime(Runtime::kToFastProperties, 1); |
2501 | 2496 |
2502 // constructor | 2497 // constructor |
2503 __ CallRuntime(Runtime::kToFastProperties, 1); | 2498 __ CallRuntime(Runtime::kToFastProperties, 1); |
2504 } | 2499 } |
2505 | 2500 |
2506 | 2501 |
2507 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 2502 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { |
2508 Token::Value op, | |
2509 OverwriteMode mode) { | |
2510 __ Pop(rdx); | 2503 __ Pop(rdx); |
2511 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); | 2504 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); |
2512 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2505 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2513 CallIC(code, expr->BinaryOperationFeedbackId()); | 2506 CallIC(code, expr->BinaryOperationFeedbackId()); |
2514 patch_site.EmitPatchInfo(); | 2507 patch_site.EmitPatchInfo(); |
2515 context()->Plug(rax); | 2508 context()->Plug(rax); |
2516 } | 2509 } |
2517 | 2510 |
2518 | 2511 |
2519 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 2512 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
2520 DCHECK(expr->IsValidReferenceExpression()); | 2513 DCHECK(expr->IsValidReferenceExpression()); |
2521 | 2514 |
(...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4792 } | 4785 } |
4793 } | 4786 } |
4794 | 4787 |
4795 // Record position before stub call. | 4788 // Record position before stub call. |
4796 SetSourcePosition(expr->position()); | 4789 SetSourcePosition(expr->position()); |
4797 | 4790 |
4798 // Call stub for +1/-1. | 4791 // Call stub for +1/-1. |
4799 __ bind(&stub_call); | 4792 __ bind(&stub_call); |
4800 __ movp(rdx, rax); | 4793 __ movp(rdx, rax); |
4801 __ Move(rax, Smi::FromInt(1)); | 4794 __ Move(rax, Smi::FromInt(1)); |
4802 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), expr->binary_op(), | 4795 Handle<Code> code = |
4803 NO_OVERWRITE).code(); | 4796 CodeFactory::BinaryOpIC(isolate(), expr->binary_op()).code(); |
4804 CallIC(code, expr->CountBinOpFeedbackId()); | 4797 CallIC(code, expr->CountBinOpFeedbackId()); |
4805 patch_site.EmitPatchInfo(); | 4798 patch_site.EmitPatchInfo(); |
4806 __ bind(&done); | 4799 __ bind(&done); |
4807 | 4800 |
4808 // Store the value returned in rax. | 4801 // Store the value returned in rax. |
4809 switch (assign_type) { | 4802 switch (assign_type) { |
4810 case VARIABLE: | 4803 case VARIABLE: |
4811 if (expr->is_postfix()) { | 4804 if (expr->is_postfix()) { |
4812 // Perform the assignment as if via '='. | 4805 // Perform the assignment as if via '='. |
4813 { EffectContext context(this); | 4806 { EffectContext context(this); |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5322 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5315 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5323 Assembler::target_address_at(call_target_address, | 5316 Assembler::target_address_at(call_target_address, |
5324 unoptimized_code)); | 5317 unoptimized_code)); |
5325 return OSR_AFTER_STACK_CHECK; | 5318 return OSR_AFTER_STACK_CHECK; |
5326 } | 5319 } |
5327 | 5320 |
5328 | 5321 |
5329 } } // namespace v8::internal | 5322 } } // namespace v8::internal |
5330 | 5323 |
5331 #endif // V8_TARGET_ARCH_X64 | 5324 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |