Index: src/x64/codegen-x64.cc |
diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc |
index d2df5a875fe962c57d3d01d7d1f3b5ff806787c6..b7a5de816a6cff7f3826741f35261c8ad23bd866 100644 |
--- a/src/x64/codegen-x64.cc |
+++ b/src/x64/codegen-x64.cc |
@@ -3877,6 +3877,49 @@ 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(); |
+ 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. |
+ Condition is_smi = __ CheckSmi(code.reg()); |
+ slow_case.Branch(NegateCondition(is_smi), not_taken); |
+ |
+ __ SmiToInteger32(kScratchRegister, code.reg()); |
+ code.Unuse(); |
+ __ cmpl(kScratchRegister, Immediate(String::kMaxAsciiCharCode)); |
+ slow_case.Branch(above, not_taken); |
+ |
+ __ Move(temp.reg(), Factory::single_character_string_cache()); |
+ __ movq(temp.reg(), Operand(temp.reg(), |
Mads Ager (chromium)
2010/02/26 17:59:06
FieldOperand to get rid of the "- kHeapObjectTag"
Vitaly Repeshko
2010/02/26 20:14:48
Done.
|
+ kScratchRegister, times_pointer_size, |
+ FixedArray::kHeaderSize - kHeapObjectTag)); |
+ __ Cmp(temp.reg(), Factory::undefined_value()); |
Mads Ager (chromium)
2010/02/26 17:59:06
You should use CompareRoot here to use the root ar
Vitaly Repeshko
2010/02/26 20:14:48
Done.
|
+ slow_case.Branch(equal, not_taken); |
+ |
+ frame_->SetElementAt(0, &temp); |
+ exit.Jump(); |
+ |
+ slow_case.Bind(); |
+ Result result = frame_->CallRuntime(Runtime::kCharFromCode, 1); |
+ frame_->Push(&result); |
+ |
+ exit.Bind(); |
+} |
+ |
+ |
void CodeGenerator::GenerateIsNonNegativeSmi(ZoneList<Expression*>* args) { |
ASSERT(args->length() == 1); |
Load(args->at(0)); |