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
This commit is contained in:
erik.corry@gmail.com 2012-09-14 12:01:12 +00:00
parent 58c8d208f5
commit a36695e853
5 changed files with 19 additions and 22 deletions

View File

@ -5232,12 +5232,12 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
// Set FixedArray length.
__ mov(r6, Operand(r5, LSL, kSmiTagSize));
__ str(r6, FieldMemOperand(r3, FixedArray::kLengthOffset));
// Fill contents of fixed-array with the-hole.
__ mov(r2, Operand(factory->the_hole_value()));
// Fill contents of fixed-array with undefined.
__ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
__ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
// Fill fixed array elements with hole.
// Fill fixed array elements with undefined.
// r0: JSArray, tagged.
// r2: the hole.
// r2: undefined.
// r3: Start of elements in FixedArray.
// r5: Number of elements to fill.
Label loop;

View File

@ -4170,15 +4170,15 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
Immediate(factory->fixed_array_map()));
// Set length.
__ mov(FieldOperand(ebx, FixedArray::kLengthOffset), ecx);
// Fill contents of fixed-array with the-hole.
// Fill contents of fixed-array with undefined.
__ SmiUntag(ecx);
__ mov(edx, Immediate(factory->the_hole_value()));
__ mov(edx, Immediate(factory->undefined_value()));
__ lea(ebx, FieldOperand(ebx, FixedArray::kHeaderSize));
// Fill fixed array elements with hole.
// Fill fixed array elements with undefined.
// eax: JSArray.
// ecx: Number of elements to fill.
// ebx: Start of elements in FixedArray.
// edx: the hole.
// edx: undefined.
Label loop;
__ test(ecx, ecx);
__ bind(&loop);

View File

@ -5405,12 +5405,12 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
// Set FixedArray length.
__ sll(t2, t1, kSmiTagSize);
__ sw(t2, FieldMemOperand(a3, FixedArray::kLengthOffset));
// Fill contents of fixed-array with the-hole.
__ li(a2, Operand(masm->isolate()->factory()->the_hole_value()));
// Fill contents of fixed-array with undefined.
__ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
__ Addu(a3, a3, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
// Fill fixed array elements with hole.
// Fill fixed array elements with undefined.
// v0: JSArray, tagged.
// a2: the hole.
// a2: undefined.
// a3: Start of elements in FixedArray.
// t1: Number of elements to fill.
Label loop;

View File

@ -140,18 +140,15 @@ function BuildResultFromMatchInfo(lastMatchInfo, s) {
var j = REGEXP_FIRST_CAPTURE + 2;
for (var i = 1; i < numResults; i++) {
start = lastMatchInfo[j++];
end = lastMatchInfo[j++];
if (end != -1) {
if (start != -1) {
end = lastMatchInfo[j];
if (start + 1 == end) {
result[i] = %_StringCharAt(s, start);
} else {
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;
}

View File

@ -3235,14 +3235,14 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
// Set length.
__ Integer32ToSmi(rdx, rbx);
__ movq(FieldOperand(rcx, FixedArray::kLengthOffset), rdx);
// Fill contents of fixed-array with the-hole.
__ LoadRoot(rdx, Heap::kTheHoleValueRootIndex);
// Fill contents of fixed-array with undefined.
__ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
__ lea(rcx, FieldOperand(rcx, FixedArray::kHeaderSize));
// Fill fixed array elements with hole.
// Fill fixed array elements with undefined.
// rax: JSArray.
// rbx: Number of elements in array that remains to be filled, as int32.
// rcx: Start of elements in FixedArray.
// rdx: the hole.
// rdx: undefined.
Label loop;
__ testl(rbx, rbx);
__ bind(&loop);