OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 6505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6516 Load(args->at(0)); | 6516 Load(args->at(0)); |
6517 Load(args->at(1)); | 6517 Load(args->at(1)); |
6518 | 6518 |
6519 StringCompareStub stub; | 6519 StringCompareStub stub; |
6520 Result answer = frame_->CallStub(&stub, 2); | 6520 Result answer = frame_->CallStub(&stub, 2); |
6521 frame_->Push(&answer); | 6521 frame_->Push(&answer); |
6522 } | 6522 } |
6523 | 6523 |
6524 | 6524 |
6525 void CodeGenerator::GenerateRegExpExec(ZoneList<Expression*>* args) { | 6525 void CodeGenerator::GenerateRegExpExec(ZoneList<Expression*>* args) { |
6526 ASSERT_EQ(args->length(), 4); | 6526 ASSERT_EQ(4, args->length()); |
6527 | 6527 |
6528 // Load the arguments on the stack and call the stub. | 6528 // Load the arguments on the stack and call the stub. |
6529 Load(args->at(0)); | 6529 Load(args->at(0)); |
6530 Load(args->at(1)); | 6530 Load(args->at(1)); |
6531 Load(args->at(2)); | 6531 Load(args->at(2)); |
6532 Load(args->at(3)); | 6532 Load(args->at(3)); |
6533 RegExpExecStub stub; | 6533 RegExpExecStub stub; |
6534 Result result = frame_->CallStub(&stub, 4); | 6534 Result result = frame_->CallStub(&stub, 4); |
6535 frame_->Push(&result); | 6535 frame_->Push(&result); |
6536 } | 6536 } |
6537 | 6537 |
6538 | 6538 |
6539 void CodeGenerator::GenerateRegExpConstructResult(ZoneList<Expression*>* args) { | |
6540 // No stub. This code only occurs a few times in regexp.js. | |
6541 const int kMaxInlineLength = 100; | |
6542 ASSERT_EQ(3, args->length()); | |
6543 Load(args->at(0)); // Size of array, smi. | |
6544 Load(args->at(1)); // "index" property value. | |
6545 Load(args->at(2)); // "input" property value. | |
6546 { | |
6547 VirtualFrame::SpilledScope spilled_scope; | |
6548 | |
6549 Label slowcase; | |
6550 Label done; | |
6551 __ mov(ebx, Operand(esp, kPointerSize * 2)); | |
6552 __ test(ebx, Immediate(0x01)); | |
Søren Thygesen Gjesse
2010/04/13 07:22:29
kHeapObjectTag?
Lasse Reichstein
2010/04/13 09:50:56
Changed to kSmiTagMask.
| |
6553 __ j(not_zero, &slowcase); | |
6554 __ cmp(Operand(ebx), Immediate(Smi::FromInt(kMaxInlineLength))); | |
6555 __ j(above, &slowcase); | |
6556 // Smi-tagging is equivalent to multiplying by 2. | |
6557 STATIC_ASSERT(kSmiTag == 0); | |
6558 STATIC_ASSERT(kSmiTagSize == 1); | |
6559 // Allocate RegExpResult followed by FixedArray with size in ebx. | |
6560 // JSArray: [Map][empty properties][Elements][Length-smi][index][input] | |
6561 // Elements: [Map][Length][..elements..] | |
6562 __ AllocateInNewSpace(JSArray::kRegExpResultSize + FixedArray::kHeaderSize, | |
Søren Thygesen Gjesse
2010/04/13 07:22:29
JSArray::kRegExpResultSize -> JSRegExpResult::kSiz
| |
6563 times_half_pointer_size, | |
Lasse Reichstein
2010/04/13 09:50:56
Done.
| |
6564 ebx, // In: Number of elements (times 2, being a smi) | |
6565 eax, // Out: Start of allocation (tagged). | |
6566 ecx, // Out: End of allocation. | |
6567 edx, // Scratch register | |
6568 &slowcase, | |
6569 TAG_OBJECT); | |
6570 // eax: Start of allocated area, object-tagged. | |
6571 | |
6572 // Set JSArray map to global.regexp_result_map(). | |
6573 // Set empty properties FixedArray. | |
6574 // Set elements to point to FixedArray allocated right after the JSArray. | |
6575 // Interleave operations for better latency. | |
6576 __ mov(edx, ContextOperand(esi, Context::GLOBAL_INDEX)); | |
6577 __ mov(ecx, Immediate(Factory::empty_fixed_array())); | |
6578 __ lea(ebx, Operand(eax, JSArray::kRegExpResultSize)); | |
6579 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalContextOffset)); | |
6580 __ mov(FieldOperand(eax, JSObject::kElementsOffset), ebx); | |
6581 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), ecx); | |
6582 __ mov(edx, ContextOperand(edx, Context::REGEXP_RESULT_MAP_INDEX)); | |
6583 __ mov(FieldOperand(eax, HeapObject::kMapOffset), edx); | |
6584 | |
6585 // Set input, index and length fields from arguments. | |
6586 __ pop(FieldOperand(eax, JSArray::kSize + kPointerSize)); | |
Søren Thygesen Gjesse
2010/04/13 07:22:29
Please add constants JSRegExpResult::kIndexOffset
Lasse Reichstein
2010/04/13 09:50:56
Done.
| |
6587 __ pop(FieldOperand(eax, JSArray::kSize)); | |
6588 __ pop(ecx); | |
6589 __ mov(FieldOperand(eax, JSArray::kLengthOffset), ecx); | |
6590 | |
6591 // Fill out the elements FixedArray. | |
6592 // eax: JSArray. | |
6593 // ebx: FixedArray. | |
6594 // ecx: Number of elements in array, as smi. | |
6595 | |
6596 // Set map. | |
6597 __ mov(FieldOperand(ebx, HeapObject::kMapOffset), | |
6598 Immediate(Factory::fixed_array_map())); | |
6599 // Set length. | |
6600 __ SmiUntag(ecx); | |
6601 __ mov(FieldOperand(ebx, FixedArray::kLengthOffset), ecx); | |
6602 // Fill contents of fixed-array with the-hole. | |
6603 __ mov(edx, Immediate(Factory::the_hole_value())); | |
6604 __ lea(ebx, FieldOperand(ebx, FixedArray::kHeaderSize)); | |
6605 // Fill fixed array elements with hole. | |
6606 // eax: JSArray. | |
6607 // ecx: Number of elements to fill. | |
6608 // ebx: Start of elements in FixedArray. | |
6609 // edx: the hole. | |
6610 Label loop; | |
6611 __ test(ecx, Operand(ecx)); | |
6612 __ bind(&loop); | |
6613 __ j(less_equal, &done); // Jump if ecx is negative or zero. | |
6614 __ sub(Operand(ecx), Immediate(1)); | |
6615 __ mov(Operand(ebx, ecx, times_pointer_size, 0), edx); | |
6616 __ jmp(&loop); | |
6617 | |
6618 __ bind(&slowcase); | |
6619 __ CallRuntime(Runtime::kRegExpConstructResult, 3); | |
6620 | |
6621 __ bind(&done); | |
6622 } | |
6623 frame_->Forget(3); | |
6624 frame_->Push(eax); | |
6625 } | |
6626 | |
6627 | |
6539 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { | 6628 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { |
6540 ASSERT_EQ(args->length(), 1); | 6629 ASSERT_EQ(args->length(), 1); |
6541 | 6630 |
6542 // Load the argument on the stack and call the stub. | 6631 // Load the argument on the stack and call the stub. |
6543 Load(args->at(0)); | 6632 Load(args->at(0)); |
6544 NumberToStringStub stub; | 6633 NumberToStringStub stub; |
6545 Result result = frame_->CallStub(&stub, 1); | 6634 Result result = frame_->CallStub(&stub, 1); |
6546 frame_->Push(&result); | 6635 frame_->Push(&result); |
6547 } | 6636 } |
6548 | 6637 |
(...skipping 6137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12686 | 12775 |
12687 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 12776 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
12688 // tagged as a small integer. | 12777 // tagged as a small integer. |
12689 __ bind(&runtime); | 12778 __ bind(&runtime); |
12690 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 12779 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
12691 } | 12780 } |
12692 | 12781 |
12693 #undef __ | 12782 #undef __ |
12694 | 12783 |
12695 } } // namespace v8::internal | 12784 } } // namespace v8::internal |
OLD | NEW |