Index: src/ia32/codegen-ia32.cc |
diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc |
index 42ab6a88df6914938abd820805cc5a7e446da570..b3c418f251a2f6bd0eae5f174fe39c21b77e60c2 100644 |
--- a/src/ia32/codegen-ia32.cc |
+++ b/src/ia32/codegen-ia32.cc |
@@ -5597,6 +5597,53 @@ void CodeGenerator::GenerateFastCharCodeAt(ZoneList<Expression*>* args) { |
} |
+void CodeGenerator::GenerateCharFromCode(ZoneList<Expression*>* args) { |
+ Comment(masm_, "[ GenerateCharFromCode"); |
+ ASSERT(args->length() == 1); |
+ |
+ Load(args->at(0)); |
+ frame_->Dup(); |
Mads Ager (chromium)
2010/02/26 17:59:06
Do you need the Dup here? You never modify code a
Vitaly Repeshko
2010/02/26 20:14:48
Well, I tried this approach and couldn't make it w
|
+ Result code = frame_->Pop(); |
+ code.ToRegister(); |
+ ASSERT(code.is_valid()); |
+ |
+ Result temp = allocator()->Allocate(); |
+ ASSERT(temp.is_valid()); |
+ |
+ JumpTarget slow_case; |
+ JumpTarget exit; |
+ |
+ // Fast case of Heap::LookupSingleCharacterStringFromCode. |
+ ASSERT(kSmiTag == 0); |
+ ASSERT(kSmiShiftSize == 0); |
+ ASSERT(IsPowerOf2(String::kMaxAsciiCharCode + 1)); |
+ __ test(code.reg(), |
+ Immediate(kSmiTagMask | |
+ ((~String::kMaxAsciiCharCode) << kSmiTagSize))); |
+ slow_case.Branch(not_zero, not_taken); |
+ |
+ __ Set(temp.reg(), Immediate(Factory::single_character_string_cache())); |
Mads Ager (chromium)
2010/02/26 17:59:06
Adding a comment here stating that code contains a
Vitaly Repeshko
2010/02/26 20:14:48
Done.
|
+ ASSERT(kSmiTag == 0); |
+ ASSERT(kSmiTagSize == 1); |
+ ASSERT(kSmiShiftSize == 0); |
+ __ mov(temp.reg(), Operand(temp.reg(), |
Mads Ager (chromium)
2010/02/26 17:59:06
Use FieldOperand and drop the "- kHeapObjectTag" o
Vitaly Repeshko
2010/02/26 20:14:48
Done.
|
+ code.reg(), times_half_pointer_size, |
+ FixedArray::kHeaderSize - kHeapObjectTag)); |
+ __ cmp(temp.reg(), Factory::undefined_value()); |
+ slow_case.Branch(equal, not_taken); |
+ code.Unuse(); |
+ |
+ frame_->SetElementAt(0, &temp); |
+ exit.Jump(); |
+ |
+ slow_case.Bind(); |
+ Result result = frame_->CallRuntime(Runtime::kCharFromCode, 1); |
+ frame_->Push(&result); |
+ |
+ exit.Bind(); |
+} |
+ |
+ |
void CodeGenerator::GenerateIsArray(ZoneList<Expression*>* args) { |
ASSERT(args->length() == 1); |
Load(args->at(0)); |