| Index: src/x64/full-codegen-x64.cc
|
| diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
|
| index 02ba67b90e3511f8943b927f1c7ad571ef44df08..d5fa5e5a7ca250543ce1645959151350f0b102cf 100644
|
| --- a/src/x64/full-codegen-x64.cc
|
| +++ b/src/x64/full-codegen-x64.cc
|
| @@ -315,9 +315,7 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
|
| reset_value = Smi::kMaxValue;
|
| }
|
| __ movq(rbx, profiling_counter_, RelocInfo::EMBEDDED_OBJECT);
|
| - __ movq(kScratchRegister,
|
| - reinterpret_cast<uint64_t>(Smi::FromInt(reset_value)),
|
| - RelocInfo::NONE64);
|
| + __ Move(kScratchRegister, Smi::FromInt(reset_value));
|
| __ movq(FieldOperand(rbx, Cell::kValueOffset), kScratchRegister);
|
| }
|
|
|
| @@ -1597,6 +1595,9 @@ void FullCodeGenerator::EmitAccessor(Expression* expression) {
|
|
|
| void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
|
| Comment cmnt(masm_, "[ ObjectLiteral");
|
| +
|
| + int depth = 1;
|
| + expr->BuildConstantProperties(isolate(), &depth);
|
| Handle<FixedArray> constant_properties = expr->constant_properties();
|
| int flags = expr->fast_elements()
|
| ? ObjectLiteral::kFastElements
|
| @@ -1606,7 +1607,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
|
| : ObjectLiteral::kNoFlags;
|
| int properties_count = constant_properties->length() / 2;
|
| if ((FLAG_track_double_fields && expr->may_store_doubles()) ||
|
| - expr->depth() > 1 || Serializer::enabled() ||
|
| + depth > 1 || Serializer::enabled() ||
|
| flags != ObjectLiteral::kFastElements ||
|
| properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
|
| __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
|
| @@ -1725,6 +1726,8 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
|
| void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
|
| Comment cmnt(masm_, "[ ArrayLiteral");
|
|
|
| + int depth = 1;
|
| + expr->BuildConstantElements(isolate(), &depth);
|
| ZoneList<Expression*>* subexprs = expr->values();
|
| int length = subexprs->length();
|
| Handle<FixedArray> constant_elements = expr->constant_elements();
|
| @@ -1751,19 +1754,13 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
|
| DONT_TRACK_ALLOCATION_SITE,
|
| length);
|
| __ CallStub(&stub);
|
| - } else if (expr->depth() > 1) {
|
| + } else if (depth > 1 || Serializer::enabled() ||
|
| + length > FastCloneShallowArrayStub::kMaximumClonedLength) {
|
| __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
|
| __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset));
|
| __ Push(Smi::FromInt(expr->literal_index()));
|
| __ Push(constant_elements);
|
| __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
|
| - } else if (Serializer::enabled() ||
|
| - length > FastCloneShallowArrayStub::kMaximumClonedLength) {
|
| - __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
|
| - __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset));
|
| - __ Push(Smi::FromInt(expr->literal_index()));
|
| - __ Push(constant_elements);
|
| - __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3);
|
| } else {
|
| ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) ||
|
| FLAG_smi_only_arrays);
|
| @@ -3029,6 +3026,33 @@ void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) {
|
| }
|
|
|
|
|
| +void FullCodeGenerator::EmitIsMinusZero(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| + ASSERT(args->length() == 1);
|
| +
|
| + VisitForAccumulatorValue(args->at(0));
|
| +
|
| + Label materialize_true, materialize_false;
|
| + Label* if_true = NULL;
|
| + Label* if_false = NULL;
|
| + Label* fall_through = NULL;
|
| + context()->PrepareTest(&materialize_true, &materialize_false,
|
| + &if_true, &if_false, &fall_through);
|
| +
|
| + Handle<Map> map = masm()->isolate()->factory()->heap_number_map();
|
| + __ CheckMap(rax, map, if_false, DO_SMI_CHECK);
|
| + __ cmpl(FieldOperand(rax, HeapNumber::kExponentOffset),
|
| + Immediate(0x80000000));
|
| + __ j(not_equal, if_false);
|
| + __ cmpl(FieldOperand(rax, HeapNumber::kMantissaOffset),
|
| + Immediate(0x00000000));
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| + Split(equal, if_true, if_false, fall_through);
|
| +
|
| + context()->Plug(if_true, if_false);
|
| +}
|
| +
|
| +
|
| void FullCodeGenerator::EmitIsArray(CallRuntime* expr) {
|
| ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
| @@ -3369,8 +3393,8 @@ void FullCodeGenerator::EmitDateField(CallRuntime* expr) {
|
| }
|
| __ bind(&runtime);
|
| __ PrepareCallCFunction(2);
|
| - __ movq(arg_reg_1, object);
|
| - __ movq(arg_reg_2, index, RelocInfo::NONE64);
|
| + __ movq(arg_reg_1, object);
|
| + __ movq(arg_reg_2, index, RelocInfo::NONE64);
|
| __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
|
| __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| __ jmp(&done);
|
| @@ -3631,11 +3655,20 @@ void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) {
|
| ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT_EQ(2, args->length());
|
|
|
| - VisitForStackValue(args->at(0));
|
| - VisitForStackValue(args->at(1));
|
| + if (FLAG_new_string_add) {
|
| + VisitForStackValue(args->at(0));
|
| + VisitForAccumulatorValue(args->at(1));
|
|
|
| - StringAddStub stub(STRING_ADD_CHECK_BOTH);
|
| - __ CallStub(&stub);
|
| + __ pop(rdx);
|
| + NewStringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED);
|
| + __ CallStub(&stub);
|
| + } else {
|
| + VisitForStackValue(args->at(0));
|
| + VisitForStackValue(args->at(1));
|
| +
|
| + StringAddStub stub(STRING_ADD_CHECK_BOTH);
|
| + __ CallStub(&stub);
|
| + }
|
| context()->Plug(rax);
|
| }
|
|
|
| @@ -3653,42 +3686,6 @@ void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitMathSin(CallRuntime* expr) {
|
| - // Load the argument on the stack and call the stub.
|
| - TranscendentalCacheStub stub(TranscendentalCache::SIN,
|
| - TranscendentalCacheStub::TAGGED);
|
| - ZoneList<Expression*>* args = expr->arguments();
|
| - ASSERT(args->length() == 1);
|
| - VisitForStackValue(args->at(0));
|
| - __ CallStub(&stub);
|
| - context()->Plug(rax);
|
| -}
|
| -
|
| -
|
| -void FullCodeGenerator::EmitMathCos(CallRuntime* expr) {
|
| - // Load the argument on the stack and call the stub.
|
| - TranscendentalCacheStub stub(TranscendentalCache::COS,
|
| - TranscendentalCacheStub::TAGGED);
|
| - ZoneList<Expression*>* args = expr->arguments();
|
| - ASSERT(args->length() == 1);
|
| - VisitForStackValue(args->at(0));
|
| - __ CallStub(&stub);
|
| - context()->Plug(rax);
|
| -}
|
| -
|
| -
|
| -void FullCodeGenerator::EmitMathTan(CallRuntime* expr) {
|
| - // Load the argument on the stack and call the stub.
|
| - TranscendentalCacheStub stub(TranscendentalCache::TAN,
|
| - TranscendentalCacheStub::TAGGED);
|
| - ZoneList<Expression*>* args = expr->arguments();
|
| - ASSERT(args->length() == 1);
|
| - VisitForStackValue(args->at(0));
|
| - __ CallStub(&stub);
|
| - context()->Plug(rax);
|
| -}
|
| -
|
| -
|
| void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
|
| // Load the argument on the stack and call the stub.
|
| TranscendentalCacheStub stub(TranscendentalCache::LOG,
|
| @@ -4384,14 +4381,47 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
|
| PrepareForBailoutForId(prop->LoadId(), TOS_REG);
|
| }
|
|
|
| - // Call ToNumber only if operand is not a smi.
|
| - Label no_conversion;
|
| + // Inline smi case if we are in a loop.
|
| + Label done, stub_call;
|
| + JumpPatchSite patch_site(masm_);
|
| if (ShouldInlineSmiCase(expr->op())) {
|
| - __ JumpIfSmi(rax, &no_conversion, Label::kNear);
|
| + Label slow;
|
| + patch_site.EmitJumpIfNotSmi(rax, &slow, Label::kNear);
|
| +
|
| + // Save result for postfix expressions.
|
| + if (expr->is_postfix()) {
|
| + if (!context()->IsEffect()) {
|
| + // Save the result on the stack. If we have a named or keyed property
|
| + // we store the result under the receiver that is currently on top
|
| + // of the stack.
|
| + switch (assign_type) {
|
| + case VARIABLE:
|
| + __ push(rax);
|
| + break;
|
| + case NAMED_PROPERTY:
|
| + __ movq(Operand(rsp, kPointerSize), rax);
|
| + break;
|
| + case KEYED_PROPERTY:
|
| + __ movq(Operand(rsp, 2 * kPointerSize), rax);
|
| + break;
|
| + }
|
| + }
|
| + }
|
| +
|
| + SmiOperationExecutionMode mode;
|
| + mode.Add(PRESERVE_SOURCE_REGISTER);
|
| + mode.Add(BAILOUT_ON_NO_OVERFLOW);
|
| + if (expr->op() == Token::INC) {
|
| + __ SmiAddConstant(rax, rax, Smi::FromInt(1), mode, &done, Label::kNear);
|
| + } else {
|
| + __ SmiSubConstant(rax, rax, Smi::FromInt(1), mode, &done, Label::kNear);
|
| + }
|
| + __ jmp(&stub_call, Label::kNear);
|
| + __ bind(&slow);
|
| }
|
| +
|
| ToNumberStub convert_stub;
|
| __ CallStub(&convert_stub);
|
| - __ bind(&no_conversion);
|
|
|
| // Save result for postfix expressions.
|
| if (expr->is_postfix()) {
|
| @@ -4413,34 +4443,11 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
|
| }
|
| }
|
|
|
| - // Inline smi case if we are in a loop.
|
| - Label done, stub_call;
|
| - JumpPatchSite patch_site(masm_);
|
| -
|
| - if (ShouldInlineSmiCase(expr->op())) {
|
| - if (expr->op() == Token::INC) {
|
| - __ SmiAddConstant(rax, rax, Smi::FromInt(1));
|
| - } else {
|
| - __ SmiSubConstant(rax, rax, Smi::FromInt(1));
|
| - }
|
| - __ j(overflow, &stub_call, Label::kNear);
|
| - // We could eliminate this smi check if we split the code at
|
| - // the first smi check before calling ToNumber.
|
| - patch_site.EmitJumpIfSmi(rax, &done, Label::kNear);
|
| -
|
| - __ bind(&stub_call);
|
| - // Call stub. Undo operation first.
|
| - if (expr->op() == Token::INC) {
|
| - __ SmiSubConstant(rax, rax, Smi::FromInt(1));
|
| - } else {
|
| - __ SmiAddConstant(rax, rax, Smi::FromInt(1));
|
| - }
|
| - }
|
| -
|
| // Record position before stub call.
|
| SetSourcePosition(expr->position());
|
|
|
| // Call stub for +1/-1.
|
| + __ bind(&stub_call);
|
| __ movq(rdx, rax);
|
| __ Move(rax, Smi::FromInt(1));
|
| BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE);
|
|
|