Chromium Code Reviews| 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 4377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4388 } | 4388 } |
| 4389 | 4389 |
| 4390 // We need a second deoptimization point after loading the value | 4390 // We need a second deoptimization point after loading the value |
| 4391 // in case evaluating the property load my have a side effect. | 4391 // in case evaluating the property load my have a side effect. |
| 4392 if (assign_type == VARIABLE) { | 4392 if (assign_type == VARIABLE) { |
| 4393 PrepareForBailout(expr->expression(), TOS_REG); | 4393 PrepareForBailout(expr->expression(), TOS_REG); |
| 4394 } else { | 4394 } else { |
| 4395 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 4395 PrepareForBailoutForId(prop->LoadId(), TOS_REG); |
| 4396 } | 4396 } |
| 4397 | 4397 |
| 4398 // Call ToNumber only if operand is not a smi. | 4398 // Inline smi case if we are in a loop. |
| 4399 Label no_conversion; | 4399 Label done, stub_call; |
| 4400 JumpPatchSite patch_site(masm_); | |
| 4400 if (ShouldInlineSmiCase(expr->op())) { | 4401 if (ShouldInlineSmiCase(expr->op())) { |
| 4401 __ JumpIfSmi(rax, &no_conversion, Label::kNear); | 4402 Label slow; |
| 4403 patch_site.EmitJumpIfNotSmi(rax, &slow, Label::kNear); | |
| 4404 | |
| 4405 // Save result for postfix expressions. | |
| 4406 if (expr->is_postfix()) { | |
| 4407 if (!context()->IsEffect()) { | |
| 4408 // Save the result on the stack. If we have a named or keyed property | |
| 4409 // we store the result under the receiver that is currently on top | |
| 4410 // of the stack. | |
| 4411 switch (assign_type) { | |
| 4412 case VARIABLE: | |
| 4413 __ push(rax); | |
| 4414 break; | |
| 4415 case NAMED_PROPERTY: | |
| 4416 __ movq(Operand(rsp, kPointerSize), rax); | |
| 4417 break; | |
| 4418 case KEYED_PROPERTY: | |
| 4419 __ movq(Operand(rsp, 2 * kPointerSize), rax); | |
| 4420 break; | |
| 4421 } | |
| 4422 } | |
| 4423 } | |
| 4424 | |
| 4425 if (expr->op() == Token::INC) { | |
|
haitao.feng
2013/08/13 09:05:57
An alternative is:
if (expr->op() == Token::IN
danno
2013/08/19 19:36:58
I think the shorter sequence is better without the
haitao.feng
2013/08/20 14:36:05
Thanks for the review and recommendation. I will m
danno
2013/08/20 15:39:37
I like your current approach where the Smi/no Smi
haitao.feng
2013/08/20 23:21:47
Thanks for the comments. Then I will port it to IA
| |
| 4426 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); | |
| 4427 } else { | |
| 4428 __ SmiSubConstant(rax, rax, Smi::FromInt(1)); | |
| 4429 } | |
| 4430 __ j(no_overflow, &done, Label::kNear); | |
| 4431 // Call stub. Undo operation first. | |
| 4432 if (expr->op() == Token::INC) { | |
| 4433 __ SmiSubConstant(rax, rax, Smi::FromInt(1)); | |
| 4434 } else { | |
| 4435 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); | |
| 4436 } | |
| 4437 __ jmp(&stub_call, Label::kNear); | |
| 4438 __ bind(&slow); | |
| 4402 } | 4439 } |
| 4440 | |
| 4403 ToNumberStub convert_stub; | 4441 ToNumberStub convert_stub; |
| 4404 __ CallStub(&convert_stub); | 4442 __ CallStub(&convert_stub); |
| 4405 __ bind(&no_conversion); | |
| 4406 | 4443 |
| 4407 // Save result for postfix expressions. | 4444 // Save result for postfix expressions. |
| 4408 if (expr->is_postfix()) { | 4445 if (expr->is_postfix()) { |
| 4409 if (!context()->IsEffect()) { | 4446 if (!context()->IsEffect()) { |
| 4410 // Save the result on the stack. If we have a named or keyed property | 4447 // Save the result on the stack. If we have a named or keyed property |
| 4411 // we store the result under the receiver that is currently on top | 4448 // we store the result under the receiver that is currently on top |
| 4412 // of the stack. | 4449 // of the stack. |
| 4413 switch (assign_type) { | 4450 switch (assign_type) { |
| 4414 case VARIABLE: | 4451 case VARIABLE: |
| 4415 __ push(rax); | 4452 __ push(rax); |
| 4416 break; | 4453 break; |
| 4417 case NAMED_PROPERTY: | 4454 case NAMED_PROPERTY: |
| 4418 __ movq(Operand(rsp, kPointerSize), rax); | 4455 __ movq(Operand(rsp, kPointerSize), rax); |
| 4419 break; | 4456 break; |
| 4420 case KEYED_PROPERTY: | 4457 case KEYED_PROPERTY: |
| 4421 __ movq(Operand(rsp, 2 * kPointerSize), rax); | 4458 __ movq(Operand(rsp, 2 * kPointerSize), rax); |
| 4422 break; | 4459 break; |
| 4423 } | 4460 } |
| 4424 } | 4461 } |
| 4425 } | 4462 } |
| 4426 | 4463 |
| 4427 // Inline smi case if we are in a loop. | |
| 4428 Label done, stub_call; | |
| 4429 JumpPatchSite patch_site(masm_); | |
| 4430 | |
| 4431 if (ShouldInlineSmiCase(expr->op())) { | |
| 4432 if (expr->op() == Token::INC) { | |
| 4433 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); | |
|
haitao.feng
2013/08/13 09:05:57
It takes me some time to understand that the origi
| |
| 4434 } else { | |
| 4435 __ SmiSubConstant(rax, rax, Smi::FromInt(1)); | |
| 4436 } | |
| 4437 __ j(overflow, &stub_call, Label::kNear); | |
| 4438 // We could eliminate this smi check if we split the code at | |
| 4439 // the first smi check before calling ToNumber. | |
|
haitao.feng
2013/08/13 09:05:57
This Cl splits the code at the first smi check.
| |
| 4440 patch_site.EmitJumpIfSmi(rax, &done, Label::kNear); | |
| 4441 | |
| 4442 __ bind(&stub_call); | |
| 4443 // Call stub. Undo operation first. | |
| 4444 if (expr->op() == Token::INC) { | |
| 4445 __ SmiSubConstant(rax, rax, Smi::FromInt(1)); | |
| 4446 } else { | |
| 4447 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); | |
| 4448 } | |
| 4449 } | |
| 4450 | |
| 4451 // Record position before stub call. | 4464 // Record position before stub call. |
| 4452 SetSourcePosition(expr->position()); | 4465 SetSourcePosition(expr->position()); |
| 4453 | 4466 |
| 4454 // Call stub for +1/-1. | 4467 // Call stub for +1/-1. |
| 4468 __ bind(&stub_call); | |
| 4455 __ movq(rdx, rax); | 4469 __ movq(rdx, rax); |
| 4456 __ Move(rax, Smi::FromInt(1)); | 4470 __ Move(rax, Smi::FromInt(1)); |
| 4457 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); | 4471 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); |
| 4458 CallIC(stub.GetCode(isolate()), | 4472 CallIC(stub.GetCode(isolate()), |
| 4459 RelocInfo::CODE_TARGET, | 4473 RelocInfo::CODE_TARGET, |
| 4460 expr->CountBinOpFeedbackId()); | 4474 expr->CountBinOpFeedbackId()); |
| 4461 patch_site.EmitPatchInfo(); | 4475 patch_site.EmitPatchInfo(); |
| 4462 __ bind(&done); | 4476 __ bind(&done); |
| 4463 | 4477 |
| 4464 // Store the value returned in rax. | 4478 // Store the value returned in rax. |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4882 *context_length = 0; | 4896 *context_length = 0; |
| 4883 return previous_; | 4897 return previous_; |
| 4884 } | 4898 } |
| 4885 | 4899 |
| 4886 | 4900 |
| 4887 #undef __ | 4901 #undef __ |
| 4888 | 4902 |
| 4889 } } // namespace v8::internal | 4903 } } // namespace v8::internal |
| 4890 | 4904 |
| 4891 #endif // V8_TARGET_ARCH_X64 | 4905 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |