Index: src/arm/codegen-arm.cc |
diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc |
index 6126898bbee446cd3dc47ba2fbfb953a65351a5a..9e8a9b8fea8803aacba277a785394d25dc2d92dd 100644 |
--- a/src/arm/codegen-arm.cc |
+++ b/src/arm/codegen-arm.cc |
@@ -3414,6 +3414,46 @@ void CodeGenerator::GenerateFastCharCodeAt(ZoneList<Expression*>* args) { |
} |
+void CodeGenerator::GenerateCharFromCode(ZoneList<Expression*>* args) { |
+ Comment(masm_, "[ GenerateCharFromCode"); |
+ ASSERT(args->length() == 1); |
+ |
+ LoadAndSpill(args->at(0)); |
+ frame_->EmitPop(r0); |
+ |
+ JumpTarget slow_case; |
+ JumpTarget exit; |
+ |
+ // Fast case of Heap::LookupSingleCharacterStringFromCode. |
+ ASSERT(kSmiTag == 0); |
+ ASSERT(kSmiShiftSize == 0); |
+ ASSERT(IsPowerOf2(String::kMaxAsciiCharCode + 1)); |
+ __ tst(r0, Operand(kSmiTagMask | |
+ ((~String::kMaxAsciiCharCode) << kSmiTagSize))); |
+ slow_case.Branch(nz); |
+ |
+ ASSERT(kSmiTag == 0); |
+ ASSERT(kSmiTagSize == 1); |
+ ASSERT(kSmiShiftSize == 0); |
+ __ mov(r1, Operand(Factory::single_character_string_cache())); |
+ __ add(r1, r1, Operand(r0)); |
Mads Ager (chromium)
2010/02/26 17:59:06
I would prefer to use
__ add(r1, r1, Operand(r0,
Vitaly Repeshko
2010/02/26 20:14:48
Done.
|
+ __ add(r1, r1, Operand(r0)); |
+ __ ldr(r1, MemOperand(r1, FixedArray::kHeaderSize - kHeapObjectTag)); |
+ __ cmp(r1, Operand(Factory::undefined_value())); |
Mads Ager (chromium)
2010/02/26 17:59:06
You should use LoadRoot to ip followed by cmp here
Vitaly Repeshko
2010/02/26 20:14:48
Done.
|
+ slow_case.Branch(eq); |
+ |
+ frame_->EmitPush(r1); |
+ exit.Jump(); |
+ |
+ slow_case.Bind(); |
+ frame_->EmitPush(r0); |
+ frame_->CallRuntime(Runtime::kCharFromCode, 1); |
+ frame_->EmitPush(r0); |
+ |
+ exit.Bind(); |
+} |
+ |
+ |
void CodeGenerator::GenerateIsArray(ZoneList<Expression*>* args) { |
VirtualFrame::SpilledScope spilled_scope; |
ASSERT(args->length() == 1); |