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

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

Issue 110573004: Merge bleeding_edge 17696:18016. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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
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 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 __ PushRoot(Heap::kNullValueRootIndex); 1589 __ PushRoot(Heap::kNullValueRootIndex);
1590 } else { 1590 } else {
1591 VisitForStackValue(expression); 1591 VisitForStackValue(expression);
1592 } 1592 }
1593 } 1593 }
1594 1594
1595 1595
1596 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1596 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1597 Comment cmnt(masm_, "[ ObjectLiteral"); 1597 Comment cmnt(masm_, "[ ObjectLiteral");
1598 1598
1599 int depth = 1; 1599 expr->BuildConstantProperties(isolate());
1600 expr->BuildConstantProperties(isolate(), &depth);
1601 Handle<FixedArray> constant_properties = expr->constant_properties(); 1600 Handle<FixedArray> constant_properties = expr->constant_properties();
1602 int flags = expr->fast_elements() 1601 int flags = expr->fast_elements()
1603 ? ObjectLiteral::kFastElements 1602 ? ObjectLiteral::kFastElements
1604 : ObjectLiteral::kNoFlags; 1603 : ObjectLiteral::kNoFlags;
1605 flags |= expr->has_function() 1604 flags |= expr->has_function()
1606 ? ObjectLiteral::kHasFunction 1605 ? ObjectLiteral::kHasFunction
1607 : ObjectLiteral::kNoFlags; 1606 : ObjectLiteral::kNoFlags;
1608 int properties_count = constant_properties->length() / 2; 1607 int properties_count = constant_properties->length() / 2;
1609 if ((FLAG_track_double_fields && expr->may_store_doubles()) || 1608 if ((FLAG_track_double_fields && expr->may_store_doubles()) ||
1610 depth > 1 || Serializer::enabled() || 1609 expr->depth() > 1 || Serializer::enabled() ||
1611 flags != ObjectLiteral::kFastElements || 1610 flags != ObjectLiteral::kFastElements ||
1612 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { 1611 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
1613 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1612 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1614 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset)); 1613 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset));
1615 __ Push(Smi::FromInt(expr->literal_index())); 1614 __ Push(Smi::FromInt(expr->literal_index()));
1616 __ Push(constant_properties); 1615 __ Push(constant_properties);
1617 __ Push(Smi::FromInt(flags)); 1616 __ Push(Smi::FromInt(flags));
1618 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1617 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1619 } else { 1618 } else {
1620 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1619 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 context()->PlugTOS(); 1718 context()->PlugTOS();
1720 } else { 1719 } else {
1721 context()->Plug(rax); 1720 context()->Plug(rax);
1722 } 1721 }
1723 } 1722 }
1724 1723
1725 1724
1726 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1725 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1727 Comment cmnt(masm_, "[ ArrayLiteral"); 1726 Comment cmnt(masm_, "[ ArrayLiteral");
1728 1727
1729 int depth = 1; 1728 expr->BuildConstantElements(isolate());
1730 expr->BuildConstantElements(isolate(), &depth);
1731 ZoneList<Expression*>* subexprs = expr->values(); 1729 ZoneList<Expression*>* subexprs = expr->values();
1732 int length = subexprs->length(); 1730 int length = subexprs->length();
1733 Handle<FixedArray> constant_elements = expr->constant_elements(); 1731 Handle<FixedArray> constant_elements = expr->constant_elements();
1734 ASSERT_EQ(2, constant_elements->length()); 1732 ASSERT_EQ(2, constant_elements->length());
1735 ElementsKind constant_elements_kind = 1733 ElementsKind constant_elements_kind =
1736 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1734 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1737 bool has_constant_fast_elements = 1735 bool has_constant_fast_elements =
1738 IsFastObjectElementsKind(constant_elements_kind); 1736 IsFastObjectElementsKind(constant_elements_kind);
1739 Handle<FixedArrayBase> constant_elements_values( 1737 Handle<FixedArrayBase> constant_elements_values(
1740 FixedArrayBase::cast(constant_elements->get(1))); 1738 FixedArrayBase::cast(constant_elements->get(1)));
1741 1739
1742 Heap* heap = isolate()->heap(); 1740 Heap* heap = isolate()->heap();
1743 if (has_constant_fast_elements && 1741 if (has_constant_fast_elements &&
1744 constant_elements_values->map() == heap->fixed_cow_array_map()) { 1742 constant_elements_values->map() == heap->fixed_cow_array_map()) {
1745 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot 1743 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot
1746 // change, so it's possible to specialize the stub in advance. 1744 // change, so it's possible to specialize the stub in advance.
1747 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); 1745 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1748 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1746 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1749 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); 1747 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset));
1750 __ Move(rbx, Smi::FromInt(expr->literal_index())); 1748 __ Move(rbx, Smi::FromInt(expr->literal_index()));
1751 __ Move(rcx, constant_elements); 1749 __ Move(rcx, constant_elements);
1752 FastCloneShallowArrayStub stub( 1750 FastCloneShallowArrayStub stub(
1753 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, 1751 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS,
1754 DONT_TRACK_ALLOCATION_SITE, 1752 DONT_TRACK_ALLOCATION_SITE,
1755 length); 1753 length);
1756 __ CallStub(&stub); 1754 __ CallStub(&stub);
1757 } else if (depth > 1 || Serializer::enabled() || 1755 } else if (expr->depth() > 1 || Serializer::enabled() ||
1758 length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1756 length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1759 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1757 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1760 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); 1758 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset));
1761 __ Push(Smi::FromInt(expr->literal_index())); 1759 __ Push(Smi::FromInt(expr->literal_index()));
1762 __ Push(constant_elements); 1760 __ Push(constant_elements);
1763 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1761 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1764 } else { 1762 } else {
1765 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || 1763 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) ||
1766 FLAG_smi_only_arrays); 1764 FLAG_smi_only_arrays);
1767 FastCloneShallowArrayStub::Mode mode = 1765 FastCloneShallowArrayStub::Mode mode =
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
3266 VisitForStackValue(args->at(1)); 3264 VisitForStackValue(args->at(1));
3267 VisitForStackValue(args->at(2)); 3265 VisitForStackValue(args->at(2));
3268 __ CallRuntime(Runtime::kLog, 2); 3266 __ CallRuntime(Runtime::kLog, 2);
3269 } 3267 }
3270 // Finally, we're expected to leave a value on the top of the stack. 3268 // Finally, we're expected to leave a value on the top of the stack.
3271 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); 3269 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
3272 context()->Plug(rax); 3270 context()->Plug(rax);
3273 } 3271 }
3274 3272
3275 3273
3276 void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) {
3277 ASSERT(expr->arguments()->length() == 0);
3278
3279 Label slow_allocate_heapnumber;
3280 Label heapnumber_allocated;
3281
3282 __ AllocateHeapNumber(rbx, rcx, &slow_allocate_heapnumber);
3283 __ jmp(&heapnumber_allocated);
3284
3285 __ bind(&slow_allocate_heapnumber);
3286 // Allocate a heap number.
3287 __ CallRuntime(Runtime::kNumberAlloc, 0);
3288 __ movq(rbx, rax);
3289
3290 __ bind(&heapnumber_allocated);
3291
3292 // Return a random uint32 number in rax.
3293 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs.
3294 __ PrepareCallCFunction(1);
3295 __ movq(arg_reg_1,
3296 ContextOperand(context_register(), Context::GLOBAL_OBJECT_INDEX));
3297 __ movq(arg_reg_1,
3298 FieldOperand(arg_reg_1, GlobalObject::kNativeContextOffset));
3299 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1);
3300
3301 // Convert 32 random bits in rax to 0.(32 random bits) in a double
3302 // by computing:
3303 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
3304 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single.
3305 __ movd(xmm1, rcx);
3306 __ movd(xmm0, rax);
3307 __ cvtss2sd(xmm1, xmm1);
3308 __ xorps(xmm0, xmm1);
3309 __ subsd(xmm0, xmm1);
3310 __ movsd(FieldOperand(rbx, HeapNumber::kValueOffset), xmm0);
3311
3312 __ movq(rax, rbx);
3313 context()->Plug(rax);
3314 }
3315
3316
3317 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { 3274 void FullCodeGenerator::EmitSubString(CallRuntime* expr) {
3318 // Load the arguments on the stack and call the stub. 3275 // Load the arguments on the stack and call the stub.
3319 SubStringStub stub; 3276 SubStringStub stub;
3320 ZoneList<Expression*>* args = expr->arguments(); 3277 ZoneList<Expression*>* args = expr->arguments();
3321 ASSERT(args->length() == 3); 3278 ASSERT(args->length() == 3);
3322 VisitForStackValue(args->at(0)); 3279 VisitForStackValue(args->at(0));
3323 VisitForStackValue(args->at(1)); 3280 VisitForStackValue(args->at(1));
3324 VisitForStackValue(args->at(2)); 3281 VisitForStackValue(args->at(2));
3325 __ CallStub(&stub); 3282 __ CallStub(&stub);
3326 context()->Plug(rax); 3283 context()->Plug(rax);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3400 __ jmp(&done); 3357 __ jmp(&done);
3401 } 3358 }
3402 3359
3403 __ bind(&not_date_object); 3360 __ bind(&not_date_object);
3404 __ CallRuntime(Runtime::kThrowNotDateError, 0); 3361 __ CallRuntime(Runtime::kThrowNotDateError, 0);
3405 __ bind(&done); 3362 __ bind(&done);
3406 context()->Plug(rax); 3363 context()->Plug(rax);
3407 } 3364 }
3408 3365
3409 3366
3410 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string,
3411 Register index,
3412 Register value,
3413 uint32_t encoding_mask) {
3414 __ Check(masm()->CheckSmi(index), kNonSmiIndex);
3415 __ Check(masm()->CheckSmi(value), kNonSmiValue);
3416
3417 __ SmiCompare(index, FieldOperand(string, String::kLengthOffset));
3418 __ Check(less, kIndexIsTooLarge);
3419
3420 __ SmiCompare(index, Smi::FromInt(0));
3421 __ Check(greater_equal, kIndexIsNegative);
3422
3423 __ push(value);
3424 __ movq(value, FieldOperand(string, HeapObject::kMapOffset));
3425 __ movzxbq(value, FieldOperand(value, Map::kInstanceTypeOffset));
3426
3427 __ andb(value, Immediate(kStringRepresentationMask | kStringEncodingMask));
3428 __ cmpq(value, Immediate(encoding_mask));
3429 __ Check(equal, kUnexpectedStringType);
3430 __ pop(value);
3431 }
3432
3433
3434 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { 3367 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
3435 ZoneList<Expression*>* args = expr->arguments(); 3368 ZoneList<Expression*>* args = expr->arguments();
3436 ASSERT_EQ(3, args->length()); 3369 ASSERT_EQ(3, args->length());
3437 3370
3438 Register string = rax; 3371 Register string = rax;
3439 Register index = rbx; 3372 Register index = rbx;
3440 Register value = rcx; 3373 Register value = rcx;
3441 3374
3442 VisitForStackValue(args->at(1)); // index 3375 VisitForStackValue(args->at(1)); // index
3443 VisitForStackValue(args->at(2)); // value 3376 VisitForStackValue(args->at(2)); // value
3377 VisitForAccumulatorValue(args->at(0)); // string
3444 __ pop(value); 3378 __ pop(value);
3445 __ pop(index); 3379 __ pop(index);
3446 VisitForAccumulatorValue(args->at(0)); // string
3447 3380
3448 if (FLAG_debug_code) { 3381 if (FLAG_debug_code) {
3449 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; 3382 __ ThrowIf(NegateCondition(__ CheckSmi(value)), kNonSmiValue);
3450 EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type); 3383 __ ThrowIf(NegateCondition(__ CheckSmi(index)), kNonSmiValue);
3451 } 3384 }
3452 3385
3453 __ SmiToInteger32(value, value); 3386 __ SmiToInteger32(value, value);
3454 __ SmiToInteger32(index, index); 3387 __ SmiToInteger32(index, index);
3388
3389 if (FLAG_debug_code) {
3390 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
3391 __ EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type);
3392 }
3393
3455 __ movb(FieldOperand(string, index, times_1, SeqOneByteString::kHeaderSize), 3394 __ movb(FieldOperand(string, index, times_1, SeqOneByteString::kHeaderSize),
3456 value); 3395 value);
3457 context()->Plug(string); 3396 context()->Plug(string);
3458 } 3397 }
3459 3398
3460 3399
3461 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { 3400 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
3462 ZoneList<Expression*>* args = expr->arguments(); 3401 ZoneList<Expression*>* args = expr->arguments();
3463 ASSERT_EQ(3, args->length()); 3402 ASSERT_EQ(3, args->length());
3464 3403
3465 Register string = rax; 3404 Register string = rax;
3466 Register index = rbx; 3405 Register index = rbx;
3467 Register value = rcx; 3406 Register value = rcx;
3468 3407
3469 VisitForStackValue(args->at(1)); // index 3408 VisitForStackValue(args->at(1)); // index
3470 VisitForStackValue(args->at(2)); // value 3409 VisitForStackValue(args->at(2)); // value
3410 VisitForAccumulatorValue(args->at(0)); // string
3471 __ pop(value); 3411 __ pop(value);
3472 __ pop(index); 3412 __ pop(index);
3473 VisitForAccumulatorValue(args->at(0)); // string
3474 3413
3475 if (FLAG_debug_code) { 3414 if (FLAG_debug_code) {
3476 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; 3415 __ ThrowIf(NegateCondition(__ CheckSmi(value)), kNonSmiValue);
3477 EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); 3416 __ ThrowIf(NegateCondition(__ CheckSmi(index)), kNonSmiValue);
3478 } 3417 }
3479 3418
3480 __ SmiToInteger32(value, value); 3419 __ SmiToInteger32(value, value);
3481 __ SmiToInteger32(index, index); 3420 __ SmiToInteger32(index, index);
3421
3422 if (FLAG_debug_code) {
3423 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
3424 __ EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type);
3425 }
3426
3482 __ movw(FieldOperand(string, index, times_2, SeqTwoByteString::kHeaderSize), 3427 __ movw(FieldOperand(string, index, times_2, SeqTwoByteString::kHeaderSize),
3483 value); 3428 value);
3484 context()->Plug(rax); 3429 context()->Plug(rax);
3485 } 3430 }
3486 3431
3487 3432
3488 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { 3433 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
3489 // Load the arguments on the stack and call the runtime function. 3434 // Load the arguments on the stack and call the runtime function.
3490 ZoneList<Expression*>* args = expr->arguments(); 3435 ZoneList<Expression*>* args = expr->arguments();
3491 ASSERT(args->length() == 2); 3436 ASSERT(args->length() == 2);
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after
4951 4896
4952 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4897 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4953 Assembler::target_address_at(call_target_address)); 4898 Assembler::target_address_at(call_target_address));
4954 return OSR_AFTER_STACK_CHECK; 4899 return OSR_AFTER_STACK_CHECK;
4955 } 4900 }
4956 4901
4957 4902
4958 } } // namespace v8::internal 4903 } } // namespace v8::internal
4959 4904
4960 #endif // V8_TARGET_ARCH_X64 4905 #endif // V8_TARGET_ARCH_X64
OLDNEW
« include/v8-platform.h ('K') | « src/x64/disasm-x64.cc ('k') | src/x64/ic-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698