Commit af09d94e authored by ager@chromium.org's avatar ager@chromium.org

ARM: support regexp literals in lithium-codegen-arm. Also, update

comment on the AllocateInNewSpace macroassembler method.

Review URL: http://codereview.chromium.org/5965014

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6192 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9a096e64
......@@ -2264,7 +2264,57 @@ void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
Abort("DoRegExpLiteral unimplemented.");
Label materialized;
// Registers will be used as follows:
// r3 = JS function.
// r7 = literals array.
// r1 = regexp literal.
// r0 = regexp literal clone.
// r2 and r4-r6 are used as temporaries.
__ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ ldr(r7, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
int literal_offset = FixedArray::kHeaderSize +
instr->hydrogen()->literal_index() * kPointerSize;
__ ldr(r1, FieldMemOperand(r7, literal_offset));
__ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
__ cmp(r1, ip);
__ b(ne, &materialized);
// Create regexp literal using runtime function
// Result will be in r0.
__ mov(r6, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
__ mov(r5, Operand(instr->hydrogen()->pattern()));
__ mov(r4, Operand(instr->hydrogen()->flags()));
__ Push(r7, r6, r5, r4);
CallRuntime(Runtime::kMaterializeRegExpLiteral, 4, instr);
__ mov(r1, r0);
__ bind(&materialized);
int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
Label allocated, runtime_allocate;
__ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
__ jmp(&allocated);
__ bind(&runtime_allocate);
__ mov(r0, Operand(Smi::FromInt(size)));
__ Push(r1, r0);
CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
__ pop(r1);
__ bind(&allocated);
// Copy the content into the newly allocated memory.
// (Unroll copy loop once for better throughput).
for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) {
__ ldr(r3, FieldMemOperand(r1, i));
__ ldr(r2, FieldMemOperand(r1, i + kPointerSize));
__ str(r3, FieldMemOperand(r0, i));
__ str(r2, FieldMemOperand(r0, i + kPointerSize));
}
if ((size % (2 * kPointerSize)) != 0) {
__ ldr(r3, FieldMemOperand(r1, size - kPointerSize));
__ str(r3, FieldMemOperand(r0, size - kPointerSize));
}
}
......
......@@ -379,12 +379,13 @@ class MacroAssembler: public Assembler {
// ---------------------------------------------------------------------------
// Allocation support
// Allocate an object in new space. The object_size is specified in words (not
// bytes). If the new space is exhausted control continues at the gc_required
// label. The allocated object is returned in result. If the flag
// tag_allocated_object is true the result is tagged as as a heap object. All
// registers are clobbered also when control continues at the gc_required
// label.
// Allocate an object in new space. The object_size is specified
// either in bytes or in words if the allocation flag SIZE_IN_WORDS
// is passed. If the new space is exhausted control continues at the
// gc_required label. The allocated object is returned in result. If
// the flag tag_allocated_object is true the result is tagged as as
// a heap object. All registers are clobbered also when control
// continues at the gc_required label.
void AllocateInNewSpace(int object_size,
Register result,
Register scratch1,
......
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