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

Side by Side Diff: src/arm/full-codegen-arm.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 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 __ push(r1); 1628 __ push(r1);
1629 } else { 1629 } else {
1630 VisitForStackValue(expression); 1630 VisitForStackValue(expression);
1631 } 1631 }
1632 } 1632 }
1633 1633
1634 1634
1635 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1635 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1636 Comment cmnt(masm_, "[ ObjectLiteral"); 1636 Comment cmnt(masm_, "[ ObjectLiteral");
1637 1637
1638 int depth = 1; 1638 expr->BuildConstantProperties(isolate());
1639 expr->BuildConstantProperties(isolate(), &depth);
1640 Handle<FixedArray> constant_properties = expr->constant_properties(); 1639 Handle<FixedArray> constant_properties = expr->constant_properties();
1641 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1640 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1642 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); 1641 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
1643 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); 1642 __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
1644 __ mov(r1, Operand(constant_properties)); 1643 __ mov(r1, Operand(constant_properties));
1645 int flags = expr->fast_elements() 1644 int flags = expr->fast_elements()
1646 ? ObjectLiteral::kFastElements 1645 ? ObjectLiteral::kFastElements
1647 : ObjectLiteral::kNoFlags; 1646 : ObjectLiteral::kNoFlags;
1648 flags |= expr->has_function() 1647 flags |= expr->has_function()
1649 ? ObjectLiteral::kHasFunction 1648 ? ObjectLiteral::kHasFunction
1650 : ObjectLiteral::kNoFlags; 1649 : ObjectLiteral::kNoFlags;
1651 __ mov(r0, Operand(Smi::FromInt(flags))); 1650 __ mov(r0, Operand(Smi::FromInt(flags)));
1652 int properties_count = constant_properties->length() / 2; 1651 int properties_count = constant_properties->length() / 2;
1653 if ((FLAG_track_double_fields && expr->may_store_doubles()) || 1652 if ((FLAG_track_double_fields && expr->may_store_doubles()) ||
1654 depth > 1 || Serializer::enabled() || 1653 expr->depth() > 1 || Serializer::enabled() ||
1655 flags != ObjectLiteral::kFastElements || 1654 flags != ObjectLiteral::kFastElements ||
1656 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { 1655 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
1657 __ Push(r3, r2, r1, r0); 1656 __ Push(r3, r2, r1, r0);
1658 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1657 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1659 } else { 1658 } else {
1660 FastCloneShallowObjectStub stub(properties_count); 1659 FastCloneShallowObjectStub stub(properties_count);
1661 __ CallStub(&stub); 1660 __ CallStub(&stub);
1662 } 1661 }
1663 1662
1664 // If result_saved is true the result is on top of the stack. If 1663 // If result_saved is true the result is on top of the stack. If
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 context()->PlugTOS(); 1762 context()->PlugTOS();
1764 } else { 1763 } else {
1765 context()->Plug(r0); 1764 context()->Plug(r0);
1766 } 1765 }
1767 } 1766 }
1768 1767
1769 1768
1770 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1769 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1771 Comment cmnt(masm_, "[ ArrayLiteral"); 1770 Comment cmnt(masm_, "[ ArrayLiteral");
1772 1771
1773 int depth = 1; 1772 expr->BuildConstantElements(isolate());
1774 expr->BuildConstantElements(isolate(), &depth);
1775 ZoneList<Expression*>* subexprs = expr->values(); 1773 ZoneList<Expression*>* subexprs = expr->values();
1776 int length = subexprs->length(); 1774 int length = subexprs->length();
1777 Handle<FixedArray> constant_elements = expr->constant_elements(); 1775 Handle<FixedArray> constant_elements = expr->constant_elements();
1778 ASSERT_EQ(2, constant_elements->length()); 1776 ASSERT_EQ(2, constant_elements->length());
1779 ElementsKind constant_elements_kind = 1777 ElementsKind constant_elements_kind =
1780 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1778 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1781 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); 1779 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind);
1782 Handle<FixedArrayBase> constant_elements_values( 1780 Handle<FixedArrayBase> constant_elements_values(
1783 FixedArrayBase::cast(constant_elements->get(1))); 1781 FixedArrayBase::cast(constant_elements->get(1)));
1784 1782
1785 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1783 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1786 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); 1784 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
1787 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); 1785 __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
1788 __ mov(r1, Operand(constant_elements)); 1786 __ mov(r1, Operand(constant_elements));
1789 if (has_fast_elements && constant_elements_values->map() == 1787 if (has_fast_elements && constant_elements_values->map() ==
1790 isolate()->heap()->fixed_cow_array_map()) { 1788 isolate()->heap()->fixed_cow_array_map()) {
1791 FastCloneShallowArrayStub stub( 1789 FastCloneShallowArrayStub stub(
1792 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, 1790 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS,
1793 DONT_TRACK_ALLOCATION_SITE, 1791 DONT_TRACK_ALLOCATION_SITE,
1794 length); 1792 length);
1795 __ CallStub(&stub); 1793 __ CallStub(&stub);
1796 __ IncrementCounter( 1794 __ IncrementCounter(
1797 isolate()->counters()->cow_arrays_created_stub(), 1, r1, r2); 1795 isolate()->counters()->cow_arrays_created_stub(), 1, r1, r2);
1798 } else if (depth > 1 || Serializer::enabled() || 1796 } else if (expr->depth() > 1 || Serializer::enabled() ||
1799 length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1797 length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1800 __ Push(r3, r2, r1); 1798 __ Push(r3, r2, r1);
1801 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1799 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1802 } else { 1800 } else {
1803 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || 1801 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) ||
1804 FLAG_smi_only_arrays); 1802 FLAG_smi_only_arrays);
1805 FastCloneShallowArrayStub::Mode mode = 1803 FastCloneShallowArrayStub::Mode mode =
1806 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; 1804 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS;
1807 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites 1805 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites
1808 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; 1806 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE;
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
3342 VisitForStackValue(args->at(2)); 3340 VisitForStackValue(args->at(2));
3343 __ CallRuntime(Runtime::kLog, 2); 3341 __ CallRuntime(Runtime::kLog, 2);
3344 } 3342 }
3345 3343
3346 // Finally, we're expected to leave a value on the top of the stack. 3344 // Finally, we're expected to leave a value on the top of the stack.
3347 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); 3345 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
3348 context()->Plug(r0); 3346 context()->Plug(r0);
3349 } 3347 }
3350 3348
3351 3349
3352 void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) {
3353 ASSERT(expr->arguments()->length() == 0);
3354 Label slow_allocate_heapnumber;
3355 Label heapnumber_allocated;
3356
3357 __ LoadRoot(r6, Heap::kHeapNumberMapRootIndex);
3358 __ AllocateHeapNumber(r4, r1, r2, r6, &slow_allocate_heapnumber);
3359 __ jmp(&heapnumber_allocated);
3360
3361 __ bind(&slow_allocate_heapnumber);
3362 // Allocate a heap number.
3363 __ CallRuntime(Runtime::kNumberAlloc, 0);
3364 __ mov(r4, Operand(r0));
3365
3366 __ bind(&heapnumber_allocated);
3367
3368 // Convert 32 random bits in r0 to 0.(32 random bits) in a double
3369 // by computing:
3370 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
3371 __ PrepareCallCFunction(1, r0);
3372 __ ldr(r0,
3373 ContextOperand(context_register(), Context::GLOBAL_OBJECT_INDEX));
3374 __ ldr(r0, FieldMemOperand(r0, GlobalObject::kNativeContextOffset));
3375 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1);
3376
3377 // 0x41300000 is the top half of 1.0 x 2^20 as a double.
3378 // Create this constant using mov/orr to avoid PC relative load.
3379 __ mov(r1, Operand(0x41000000));
3380 __ orr(r1, r1, Operand(0x300000));
3381 // Move 0x41300000xxxxxxxx (x = random bits) to VFP.
3382 __ vmov(d7, r0, r1);
3383 // Move 0x4130000000000000 to VFP.
3384 __ mov(r0, Operand::Zero());
3385 __ vmov(d8, r0, r1);
3386 // Subtract and store the result in the heap number.
3387 __ vsub(d7, d7, d8);
3388 __ sub(r0, r4, Operand(kHeapObjectTag));
3389 __ vstr(d7, r0, HeapNumber::kValueOffset);
3390 __ mov(r0, r4);
3391
3392 context()->Plug(r0);
3393 }
3394
3395
3396 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { 3350 void FullCodeGenerator::EmitSubString(CallRuntime* expr) {
3397 // Load the arguments on the stack and call the stub. 3351 // Load the arguments on the stack and call the stub.
3398 SubStringStub stub; 3352 SubStringStub stub;
3399 ZoneList<Expression*>* args = expr->arguments(); 3353 ZoneList<Expression*>* args = expr->arguments();
3400 ASSERT(args->length() == 3); 3354 ASSERT(args->length() == 3);
3401 VisitForStackValue(args->at(0)); 3355 VisitForStackValue(args->at(0));
3402 VisitForStackValue(args->at(1)); 3356 VisitForStackValue(args->at(1));
3403 VisitForStackValue(args->at(2)); 3357 VisitForStackValue(args->at(2));
3404 __ CallStub(&stub); 3358 __ CallStub(&stub);
3405 context()->Plug(r0); 3359 context()->Plug(r0);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3478 __ jmp(&done); 3432 __ jmp(&done);
3479 } 3433 }
3480 3434
3481 __ bind(&not_date_object); 3435 __ bind(&not_date_object);
3482 __ CallRuntime(Runtime::kThrowNotDateError, 0); 3436 __ CallRuntime(Runtime::kThrowNotDateError, 0);
3483 __ bind(&done); 3437 __ bind(&done);
3484 context()->Plug(r0); 3438 context()->Plug(r0);
3485 } 3439 }
3486 3440
3487 3441
3488 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string,
3489 Register index,
3490 Register value,
3491 uint32_t encoding_mask) {
3492 __ SmiTst(index);
3493 __ Check(eq, kNonSmiIndex);
3494 __ SmiTst(value);
3495 __ Check(eq, kNonSmiValue);
3496
3497 __ ldr(ip, FieldMemOperand(string, String::kLengthOffset));
3498 __ cmp(index, ip);
3499 __ Check(lt, kIndexIsTooLarge);
3500
3501 __ cmp(index, Operand(Smi::FromInt(0)));
3502 __ Check(ge, kIndexIsNegative);
3503
3504 __ ldr(ip, FieldMemOperand(string, HeapObject::kMapOffset));
3505 __ ldrb(ip, FieldMemOperand(ip, Map::kInstanceTypeOffset));
3506
3507 __ and_(ip, ip, Operand(kStringRepresentationMask | kStringEncodingMask));
3508 __ cmp(ip, Operand(encoding_mask));
3509 __ Check(eq, kUnexpectedStringType);
3510 }
3511
3512
3513 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { 3442 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
3514 ZoneList<Expression*>* args = expr->arguments(); 3443 ZoneList<Expression*>* args = expr->arguments();
3515 ASSERT_EQ(3, args->length()); 3444 ASSERT_EQ(3, args->length());
3516 3445
3517 Register string = r0; 3446 Register string = r0;
3518 Register index = r1; 3447 Register index = r1;
3519 Register value = r2; 3448 Register value = r2;
3520 3449
3521 VisitForStackValue(args->at(1)); // index 3450 VisitForStackValue(args->at(1)); // index
3522 VisitForStackValue(args->at(2)); // value 3451 VisitForStackValue(args->at(2)); // value
3452 VisitForAccumulatorValue(args->at(0)); // string
3523 __ Pop(index, value); 3453 __ Pop(index, value);
3524 VisitForAccumulatorValue(args->at(0)); // string
3525 3454
3526 if (FLAG_debug_code) { 3455 if (FLAG_debug_code) {
3456 __ SmiTst(value);
3457 __ ThrowIf(ne, kNonSmiValue);
3458 __ SmiTst(index);
3459 __ ThrowIf(ne, kNonSmiIndex);
3460 __ SmiUntag(index, index);
3527 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; 3461 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
3528 EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type); 3462 __ EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type);
3463 __ SmiTag(index, index);
3529 } 3464 }
3530 3465
3531 __ SmiUntag(value, value); 3466 __ SmiUntag(value, value);
3532 __ add(ip, 3467 __ add(ip,
3533 string, 3468 string,
3534 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); 3469 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag));
3535 __ strb(value, MemOperand(ip, index, LSR, kSmiTagSize)); 3470 __ strb(value, MemOperand(ip, index, LSR, kSmiTagSize));
3536 context()->Plug(string); 3471 context()->Plug(string);
3537 } 3472 }
3538 3473
3539 3474
3540 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { 3475 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
3541 ZoneList<Expression*>* args = expr->arguments(); 3476 ZoneList<Expression*>* args = expr->arguments();
3542 ASSERT_EQ(3, args->length()); 3477 ASSERT_EQ(3, args->length());
3543 3478
3544 Register string = r0; 3479 Register string = r0;
3545 Register index = r1; 3480 Register index = r1;
3546 Register value = r2; 3481 Register value = r2;
3547 3482
3548 VisitForStackValue(args->at(1)); // index 3483 VisitForStackValue(args->at(1)); // index
3549 VisitForStackValue(args->at(2)); // value 3484 VisitForStackValue(args->at(2)); // value
3485 VisitForAccumulatorValue(args->at(0)); // string
3550 __ Pop(index, value); 3486 __ Pop(index, value);
3551 VisitForAccumulatorValue(args->at(0)); // string
3552 3487
3553 if (FLAG_debug_code) { 3488 if (FLAG_debug_code) {
3489 __ SmiTst(value);
3490 __ ThrowIf(ne, kNonSmiValue);
3491 __ SmiTst(index);
3492 __ ThrowIf(ne, kNonSmiIndex);
3493 __ SmiUntag(index, index);
3554 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; 3494 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
3555 EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); 3495 __ EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type);
3496 __ SmiTag(index, index);
3556 } 3497 }
3557 3498
3558 __ SmiUntag(value, value); 3499 __ SmiUntag(value, value);
3559 __ add(ip, 3500 __ add(ip,
3560 string, 3501 string,
3561 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); 3502 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
3562 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 3503 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
3563 __ strh(value, MemOperand(ip, index)); 3504 __ strh(value, MemOperand(ip, index));
3564 context()->Plug(string); 3505 context()->Plug(string);
3565 } 3506 }
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
4978 ASSERT(Memory::uint32_at(interrupt_address_pointer) == 4919 ASSERT(Memory::uint32_at(interrupt_address_pointer) ==
4979 reinterpret_cast<uint32_t>( 4920 reinterpret_cast<uint32_t>(
4980 isolate->builtins()->OsrAfterStackCheck()->entry())); 4921 isolate->builtins()->OsrAfterStackCheck()->entry()));
4981 return OSR_AFTER_STACK_CHECK; 4922 return OSR_AFTER_STACK_CHECK;
4982 } 4923 }
4983 4924
4984 4925
4985 } } // namespace v8::internal 4926 } } // namespace v8::internal
4986 4927
4987 #endif // V8_TARGET_ARCH_ARM 4928 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« include/v8-platform.h ('K') | « src/arm/frames-arm.h ('k') | src/arm/ic-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698