Commit a36695e8 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Microoptimization to regexps.

Review URL: https://chromiumcodereview.appspot.com/10917260

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12511 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 58c8d208
...@@ -5232,12 +5232,12 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) { ...@@ -5232,12 +5232,12 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
// Set FixedArray length. // Set FixedArray length.
__ mov(r6, Operand(r5, LSL, kSmiTagSize)); __ mov(r6, Operand(r5, LSL, kSmiTagSize));
__ str(r6, FieldMemOperand(r3, FixedArray::kLengthOffset)); __ str(r6, FieldMemOperand(r3, FixedArray::kLengthOffset));
// Fill contents of fixed-array with the-hole. // Fill contents of fixed-array with undefined.
__ mov(r2, Operand(factory->the_hole_value())); __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
__ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
// Fill fixed array elements with hole. // Fill fixed array elements with undefined.
// r0: JSArray, tagged. // r0: JSArray, tagged.
// r2: the hole. // r2: undefined.
// r3: Start of elements in FixedArray. // r3: Start of elements in FixedArray.
// r5: Number of elements to fill. // r5: Number of elements to fill.
Label loop; Label loop;
......
...@@ -4170,15 +4170,15 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) { ...@@ -4170,15 +4170,15 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
Immediate(factory->fixed_array_map())); Immediate(factory->fixed_array_map()));
// Set length. // Set length.
__ mov(FieldOperand(ebx, FixedArray::kLengthOffset), ecx); __ mov(FieldOperand(ebx, FixedArray::kLengthOffset), ecx);
// Fill contents of fixed-array with the-hole. // Fill contents of fixed-array with undefined.
__ SmiUntag(ecx); __ SmiUntag(ecx);
__ mov(edx, Immediate(factory->the_hole_value())); __ mov(edx, Immediate(factory->undefined_value()));
__ lea(ebx, FieldOperand(ebx, FixedArray::kHeaderSize)); __ lea(ebx, FieldOperand(ebx, FixedArray::kHeaderSize));
// Fill fixed array elements with hole. // Fill fixed array elements with undefined.
// eax: JSArray. // eax: JSArray.
// ecx: Number of elements to fill. // ecx: Number of elements to fill.
// ebx: Start of elements in FixedArray. // ebx: Start of elements in FixedArray.
// edx: the hole. // edx: undefined.
Label loop; Label loop;
__ test(ecx, ecx); __ test(ecx, ecx);
__ bind(&loop); __ bind(&loop);
......
...@@ -5405,12 +5405,12 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) { ...@@ -5405,12 +5405,12 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
// Set FixedArray length. // Set FixedArray length.
__ sll(t2, t1, kSmiTagSize); __ sll(t2, t1, kSmiTagSize);
__ sw(t2, FieldMemOperand(a3, FixedArray::kLengthOffset)); __ sw(t2, FieldMemOperand(a3, FixedArray::kLengthOffset));
// Fill contents of fixed-array with the-hole. // Fill contents of fixed-array with undefined.
__ li(a2, Operand(masm->isolate()->factory()->the_hole_value())); __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
__ Addu(a3, a3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); __ Addu(a3, a3, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
// Fill fixed array elements with hole. // Fill fixed array elements with undefined.
// v0: JSArray, tagged. // v0: JSArray, tagged.
// a2: the hole. // a2: undefined.
// a3: Start of elements in FixedArray. // a3: Start of elements in FixedArray.
// t1: Number of elements to fill. // t1: Number of elements to fill.
Label loop; Label loop;
......
...@@ -140,18 +140,15 @@ function BuildResultFromMatchInfo(lastMatchInfo, s) { ...@@ -140,18 +140,15 @@ function BuildResultFromMatchInfo(lastMatchInfo, s) {
var j = REGEXP_FIRST_CAPTURE + 2; var j = REGEXP_FIRST_CAPTURE + 2;
for (var i = 1; i < numResults; i++) { for (var i = 1; i < numResults; i++) {
start = lastMatchInfo[j++]; start = lastMatchInfo[j++];
end = lastMatchInfo[j++]; if (start != -1) {
if (end != -1) { end = lastMatchInfo[j];
if (start + 1 == end) { if (start + 1 == end) {
result[i] = %_StringCharAt(s, start); result[i] = %_StringCharAt(s, start);
} else { } else {
result[i] = %_SubString(s, start, end); result[i] = %_SubString(s, start, end);
} }
} else {
// Make sure the element is present. Avoid reading the undefined
// property from the global object since this may change.
result[i] = void 0;
} }
j++;
} }
return result; return result;
} }
......
...@@ -3235,14 +3235,14 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) { ...@@ -3235,14 +3235,14 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
// Set length. // Set length.
__ Integer32ToSmi(rdx, rbx); __ Integer32ToSmi(rdx, rbx);
__ movq(FieldOperand(rcx, FixedArray::kLengthOffset), rdx); __ movq(FieldOperand(rcx, FixedArray::kLengthOffset), rdx);
// Fill contents of fixed-array with the-hole. // Fill contents of fixed-array with undefined.
__ LoadRoot(rdx, Heap::kTheHoleValueRootIndex); __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
__ lea(rcx, FieldOperand(rcx, FixedArray::kHeaderSize)); __ lea(rcx, FieldOperand(rcx, FixedArray::kHeaderSize));
// Fill fixed array elements with hole. // Fill fixed array elements with undefined.
// rax: JSArray. // rax: JSArray.
// rbx: Number of elements in array that remains to be filled, as int32. // rbx: Number of elements in array that remains to be filled, as int32.
// rcx: Start of elements in FixedArray. // rcx: Start of elements in FixedArray.
// rdx: the hole. // rdx: undefined.
Label loop; Label loop;
__ testl(rbx, rbx); __ testl(rbx, rbx);
__ bind(&loop); __ bind(&loop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment