Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 132373011: A64: Synchronize with r17635. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/debug-x64.cc ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 309
310 310
311 void FullCodeGenerator::EmitProfilingCounterReset() { 311 void FullCodeGenerator::EmitProfilingCounterReset() {
312 int reset_value = FLAG_interrupt_budget; 312 int reset_value = FLAG_interrupt_budget;
313 if (info_->ShouldSelfOptimize() && !FLAG_retry_self_opt) { 313 if (info_->ShouldSelfOptimize() && !FLAG_retry_self_opt) {
314 // Self-optimization is a one-off thing; if it fails, don't try again. 314 // Self-optimization is a one-off thing; if it fails, don't try again.
315 reset_value = Smi::kMaxValue; 315 reset_value = Smi::kMaxValue;
316 } 316 }
317 __ movq(rbx, profiling_counter_, RelocInfo::EMBEDDED_OBJECT); 317 __ movq(rbx, profiling_counter_, RelocInfo::EMBEDDED_OBJECT);
318 __ movq(kScratchRegister, 318 __ Move(kScratchRegister, Smi::FromInt(reset_value));
319 reinterpret_cast<uint64_t>(Smi::FromInt(reset_value)),
320 RelocInfo::NONE64);
321 __ movq(FieldOperand(rbx, Cell::kValueOffset), kScratchRegister); 319 __ movq(FieldOperand(rbx, Cell::kValueOffset), kScratchRegister);
322 } 320 }
323 321
324 322
325 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, 323 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt,
326 Label* back_edge_target) { 324 Label* back_edge_target) {
327 Comment cmnt(masm_, "[ Back edge bookkeeping"); 325 Comment cmnt(masm_, "[ Back edge bookkeeping");
328 Label ok; 326 Label ok;
329 327
330 int weight = 1; 328 int weight = 1;
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 if (expression == NULL) { 1588 if (expression == NULL) {
1591 __ PushRoot(Heap::kNullValueRootIndex); 1589 __ PushRoot(Heap::kNullValueRootIndex);
1592 } else { 1590 } else {
1593 VisitForStackValue(expression); 1591 VisitForStackValue(expression);
1594 } 1592 }
1595 } 1593 }
1596 1594
1597 1595
1598 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1596 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1599 Comment cmnt(masm_, "[ ObjectLiteral"); 1597 Comment cmnt(masm_, "[ ObjectLiteral");
1598
1599 int depth = 1;
1600 expr->BuildConstantProperties(isolate(), &depth);
1600 Handle<FixedArray> constant_properties = expr->constant_properties(); 1601 Handle<FixedArray> constant_properties = expr->constant_properties();
1601 int flags = expr->fast_elements() 1602 int flags = expr->fast_elements()
1602 ? ObjectLiteral::kFastElements 1603 ? ObjectLiteral::kFastElements
1603 : ObjectLiteral::kNoFlags; 1604 : ObjectLiteral::kNoFlags;
1604 flags |= expr->has_function() 1605 flags |= expr->has_function()
1605 ? ObjectLiteral::kHasFunction 1606 ? ObjectLiteral::kHasFunction
1606 : ObjectLiteral::kNoFlags; 1607 : ObjectLiteral::kNoFlags;
1607 int properties_count = constant_properties->length() / 2; 1608 int properties_count = constant_properties->length() / 2;
1608 if ((FLAG_track_double_fields && expr->may_store_doubles()) || 1609 if ((FLAG_track_double_fields && expr->may_store_doubles()) ||
1609 expr->depth() > 1 || Serializer::enabled() || 1610 depth > 1 || Serializer::enabled() ||
1610 flags != ObjectLiteral::kFastElements || 1611 flags != ObjectLiteral::kFastElements ||
1611 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { 1612 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
1612 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1613 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1613 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset)); 1614 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset));
1614 __ Push(Smi::FromInt(expr->literal_index())); 1615 __ Push(Smi::FromInt(expr->literal_index()));
1615 __ Push(constant_properties); 1616 __ Push(constant_properties);
1616 __ Push(Smi::FromInt(flags)); 1617 __ Push(Smi::FromInt(flags));
1617 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1618 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1618 } else { 1619 } else {
1619 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1620 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 context()->PlugTOS(); 1719 context()->PlugTOS();
1719 } else { 1720 } else {
1720 context()->Plug(rax); 1721 context()->Plug(rax);
1721 } 1722 }
1722 } 1723 }
1723 1724
1724 1725
1725 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1726 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1726 Comment cmnt(masm_, "[ ArrayLiteral"); 1727 Comment cmnt(masm_, "[ ArrayLiteral");
1727 1728
1729 int depth = 1;
1730 expr->BuildConstantElements(isolate(), &depth);
1728 ZoneList<Expression*>* subexprs = expr->values(); 1731 ZoneList<Expression*>* subexprs = expr->values();
1729 int length = subexprs->length(); 1732 int length = subexprs->length();
1730 Handle<FixedArray> constant_elements = expr->constant_elements(); 1733 Handle<FixedArray> constant_elements = expr->constant_elements();
1731 ASSERT_EQ(2, constant_elements->length()); 1734 ASSERT_EQ(2, constant_elements->length());
1732 ElementsKind constant_elements_kind = 1735 ElementsKind constant_elements_kind =
1733 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1736 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1734 bool has_constant_fast_elements = 1737 bool has_constant_fast_elements =
1735 IsFastObjectElementsKind(constant_elements_kind); 1738 IsFastObjectElementsKind(constant_elements_kind);
1736 Handle<FixedArrayBase> constant_elements_values( 1739 Handle<FixedArrayBase> constant_elements_values(
1737 FixedArrayBase::cast(constant_elements->get(1))); 1740 FixedArrayBase::cast(constant_elements->get(1)));
1738 1741
1739 Heap* heap = isolate()->heap(); 1742 Heap* heap = isolate()->heap();
1740 if (has_constant_fast_elements && 1743 if (has_constant_fast_elements &&
1741 constant_elements_values->map() == heap->fixed_cow_array_map()) { 1744 constant_elements_values->map() == heap->fixed_cow_array_map()) {
1742 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot 1745 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot
1743 // change, so it's possible to specialize the stub in advance. 1746 // change, so it's possible to specialize the stub in advance.
1744 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); 1747 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1745 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1748 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1746 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); 1749 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset));
1747 __ Move(rbx, Smi::FromInt(expr->literal_index())); 1750 __ Move(rbx, Smi::FromInt(expr->literal_index()));
1748 __ Move(rcx, constant_elements); 1751 __ Move(rcx, constant_elements);
1749 FastCloneShallowArrayStub stub( 1752 FastCloneShallowArrayStub stub(
1750 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, 1753 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS,
1751 DONT_TRACK_ALLOCATION_SITE, 1754 DONT_TRACK_ALLOCATION_SITE,
1752 length); 1755 length);
1753 __ CallStub(&stub); 1756 __ CallStub(&stub);
1754 } else if (expr->depth() > 1 || 1757 } else if (depth > 1 || Serializer::enabled() ||
1755 Serializer::enabled() ||
1756 length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1758 length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1757 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1759 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1758 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); 1760 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset));
1759 __ Push(Smi::FromInt(expr->literal_index())); 1761 __ Push(Smi::FromInt(expr->literal_index()));
1760 __ Push(constant_elements); 1762 __ Push(constant_elements);
1761 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1763 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1762 } else { 1764 } else {
1763 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || 1765 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) ||
1764 FLAG_smi_only_arrays); 1766 FLAG_smi_only_arrays);
1765 FastCloneShallowArrayStub::Mode mode = 1767 FastCloneShallowArrayStub::Mode mode =
(...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after
3357 Operand stamp_operand = __ ExternalOperand(stamp); 3359 Operand stamp_operand = __ ExternalOperand(stamp);
3358 __ movq(scratch, stamp_operand); 3360 __ movq(scratch, stamp_operand);
3359 __ cmpq(scratch, FieldOperand(object, JSDate::kCacheStampOffset)); 3361 __ cmpq(scratch, FieldOperand(object, JSDate::kCacheStampOffset));
3360 __ j(not_equal, &runtime, Label::kNear); 3362 __ j(not_equal, &runtime, Label::kNear);
3361 __ movq(result, FieldOperand(object, JSDate::kValueOffset + 3363 __ movq(result, FieldOperand(object, JSDate::kValueOffset +
3362 kPointerSize * index->value())); 3364 kPointerSize * index->value()));
3363 __ jmp(&done); 3365 __ jmp(&done);
3364 } 3366 }
3365 __ bind(&runtime); 3367 __ bind(&runtime);
3366 __ PrepareCallCFunction(2); 3368 __ PrepareCallCFunction(2);
3367 __ movq(arg_reg_1, object); 3369 __ movq(arg_reg_1, object);
3368 __ movq(arg_reg_2, index, RelocInfo::NONE64); 3370 __ movq(arg_reg_2, index, RelocInfo::NONE64);
3369 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); 3371 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
3370 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 3372 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
3371 __ jmp(&done); 3373 __ jmp(&done);
3372 } 3374 }
3373 3375
3374 __ bind(&not_date_object); 3376 __ bind(&not_date_object);
3375 __ CallRuntime(Runtime::kThrowNotDateError, 0); 3377 __ CallRuntime(Runtime::kThrowNotDateError, 0);
3376 __ bind(&done); 3378 __ bind(&done);
3377 context()->Plug(rax); 3379 context()->Plug(rax);
3378 } 3380 }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
3619 3621
3620 __ bind(&done); 3622 __ bind(&done);
3621 context()->Plug(result); 3623 context()->Plug(result);
3622 } 3624 }
3623 3625
3624 3626
3625 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { 3627 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) {
3626 ZoneList<Expression*>* args = expr->arguments(); 3628 ZoneList<Expression*>* args = expr->arguments();
3627 ASSERT_EQ(2, args->length()); 3629 ASSERT_EQ(2, args->length());
3628 3630
3629 VisitForStackValue(args->at(0)); 3631 if (FLAG_new_string_add) {
3630 VisitForStackValue(args->at(1)); 3632 VisitForStackValue(args->at(0));
3633 VisitForAccumulatorValue(args->at(1));
3631 3634
3632 StringAddStub stub(STRING_ADD_CHECK_BOTH); 3635 __ pop(rdx);
3633 __ CallStub(&stub); 3636 NewStringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED);
3637 __ CallStub(&stub);
3638 } else {
3639 VisitForStackValue(args->at(0));
3640 VisitForStackValue(args->at(1));
3641
3642 StringAddStub stub(STRING_ADD_CHECK_BOTH);
3643 __ CallStub(&stub);
3644 }
3634 context()->Plug(rax); 3645 context()->Plug(rax);
3635 } 3646 }
3636 3647
3637 3648
3638 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { 3649 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
3639 ZoneList<Expression*>* args = expr->arguments(); 3650 ZoneList<Expression*>* args = expr->arguments();
3640 ASSERT_EQ(2, args->length()); 3651 ASSERT_EQ(2, args->length());
3641 3652
3642 VisitForStackValue(args->at(0)); 3653 VisitForStackValue(args->at(0));
3643 VisitForStackValue(args->at(1)); 3654 VisitForStackValue(args->at(1));
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
4372 } 4383 }
4373 4384
4374 // We need a second deoptimization point after loading the value 4385 // We need a second deoptimization point after loading the value
4375 // in case evaluating the property load my have a side effect. 4386 // in case evaluating the property load my have a side effect.
4376 if (assign_type == VARIABLE) { 4387 if (assign_type == VARIABLE) {
4377 PrepareForBailout(expr->expression(), TOS_REG); 4388 PrepareForBailout(expr->expression(), TOS_REG);
4378 } else { 4389 } else {
4379 PrepareForBailoutForId(prop->LoadId(), TOS_REG); 4390 PrepareForBailoutForId(prop->LoadId(), TOS_REG);
4380 } 4391 }
4381 4392
4382 // Call ToNumber only if operand is not a smi. 4393 // Inline smi case if we are in a loop.
4383 Label no_conversion; 4394 Label done, stub_call;
4395 JumpPatchSite patch_site(masm_);
4384 if (ShouldInlineSmiCase(expr->op())) { 4396 if (ShouldInlineSmiCase(expr->op())) {
4385 __ JumpIfSmi(rax, &no_conversion, Label::kNear); 4397 Label slow;
4398 patch_site.EmitJumpIfNotSmi(rax, &slow, Label::kNear);
4399
4400 // Save result for postfix expressions.
4401 if (expr->is_postfix()) {
4402 if (!context()->IsEffect()) {
4403 // Save the result on the stack. If we have a named or keyed property
4404 // we store the result under the receiver that is currently on top
4405 // of the stack.
4406 switch (assign_type) {
4407 case VARIABLE:
4408 __ push(rax);
4409 break;
4410 case NAMED_PROPERTY:
4411 __ movq(Operand(rsp, kPointerSize), rax);
4412 break;
4413 case KEYED_PROPERTY:
4414 __ movq(Operand(rsp, 2 * kPointerSize), rax);
4415 break;
4416 }
4417 }
4418 }
4419
4420 SmiOperationExecutionMode mode;
4421 mode.Add(PRESERVE_SOURCE_REGISTER);
4422 mode.Add(BAILOUT_ON_NO_OVERFLOW);
4423 if (expr->op() == Token::INC) {
4424 __ SmiAddConstant(rax, rax, Smi::FromInt(1), mode, &done, Label::kNear);
4425 } else {
4426 __ SmiSubConstant(rax, rax, Smi::FromInt(1), mode, &done, Label::kNear);
4427 }
4428 __ jmp(&stub_call, Label::kNear);
4429 __ bind(&slow);
4386 } 4430 }
4431
4387 ToNumberStub convert_stub; 4432 ToNumberStub convert_stub;
4388 __ CallStub(&convert_stub); 4433 __ CallStub(&convert_stub);
4389 __ bind(&no_conversion);
4390 4434
4391 // Save result for postfix expressions. 4435 // Save result for postfix expressions.
4392 if (expr->is_postfix()) { 4436 if (expr->is_postfix()) {
4393 if (!context()->IsEffect()) { 4437 if (!context()->IsEffect()) {
4394 // Save the result on the stack. If we have a named or keyed property 4438 // Save the result on the stack. If we have a named or keyed property
4395 // we store the result under the receiver that is currently on top 4439 // we store the result under the receiver that is currently on top
4396 // of the stack. 4440 // of the stack.
4397 switch (assign_type) { 4441 switch (assign_type) {
4398 case VARIABLE: 4442 case VARIABLE:
4399 __ push(rax); 4443 __ push(rax);
4400 break; 4444 break;
4401 case NAMED_PROPERTY: 4445 case NAMED_PROPERTY:
4402 __ movq(Operand(rsp, kPointerSize), rax); 4446 __ movq(Operand(rsp, kPointerSize), rax);
4403 break; 4447 break;
4404 case KEYED_PROPERTY: 4448 case KEYED_PROPERTY:
4405 __ movq(Operand(rsp, 2 * kPointerSize), rax); 4449 __ movq(Operand(rsp, 2 * kPointerSize), rax);
4406 break; 4450 break;
4407 } 4451 }
4408 } 4452 }
4409 } 4453 }
4410 4454
4411 // Inline smi case if we are in a loop.
4412 Label done, stub_call;
4413 JumpPatchSite patch_site(masm_);
4414
4415 if (ShouldInlineSmiCase(expr->op())) {
4416 if (expr->op() == Token::INC) {
4417 __ SmiAddConstant(rax, rax, Smi::FromInt(1));
4418 } else {
4419 __ SmiSubConstant(rax, rax, Smi::FromInt(1));
4420 }
4421 __ j(overflow, &stub_call, Label::kNear);
4422 // We could eliminate this smi check if we split the code at
4423 // the first smi check before calling ToNumber.
4424 patch_site.EmitJumpIfSmi(rax, &done, Label::kNear);
4425
4426 __ bind(&stub_call);
4427 // Call stub. Undo operation first.
4428 if (expr->op() == Token::INC) {
4429 __ SmiSubConstant(rax, rax, Smi::FromInt(1));
4430 } else {
4431 __ SmiAddConstant(rax, rax, Smi::FromInt(1));
4432 }
4433 }
4434
4435 // Record position before stub call. 4455 // Record position before stub call.
4436 SetSourcePosition(expr->position()); 4456 SetSourcePosition(expr->position());
4437 4457
4438 // Call stub for +1/-1. 4458 // Call stub for +1/-1.
4459 __ bind(&stub_call);
4439 __ movq(rdx, rax); 4460 __ movq(rdx, rax);
4440 __ Move(rax, Smi::FromInt(1)); 4461 __ Move(rax, Smi::FromInt(1));
4441 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); 4462 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE);
4442 CallIC(stub.GetCode(isolate()), 4463 CallIC(stub.GetCode(isolate()),
4443 RelocInfo::CODE_TARGET, 4464 RelocInfo::CODE_TARGET,
4444 expr->CountBinOpFeedbackId()); 4465 expr->CountBinOpFeedbackId());
4445 patch_site.EmitPatchInfo(); 4466 patch_site.EmitPatchInfo();
4446 __ bind(&done); 4467 __ bind(&done);
4447 4468
4448 // Store the value returned in rax. 4469 // Store the value returned in rax.
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
4939 4960
4940 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4961 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4941 Assembler::target_address_at(call_target_address)); 4962 Assembler::target_address_at(call_target_address));
4942 return OSR_AFTER_STACK_CHECK; 4963 return OSR_AFTER_STACK_CHECK;
4943 } 4964 }
4944 4965
4945 4966
4946 } } // namespace v8::internal 4967 } } // namespace v8::internal
4947 4968
4948 #endif // V8_TARGET_ARCH_X64 4969 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/debug-x64.cc ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698