OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4111 __ bind(&slowcase); | 4111 __ bind(&slowcase); |
4112 __ CallRuntime(Runtime::kRegExpConstructResult, 3); | 4112 __ CallRuntime(Runtime::kRegExpConstructResult, 3); |
4113 | 4113 |
4114 __ bind(&done); | 4114 __ bind(&done); |
4115 } | 4115 } |
4116 frame_->Forget(3); | 4116 frame_->Forget(3); |
4117 frame_->EmitPush(r0); | 4117 frame_->EmitPush(r0); |
4118 } | 4118 } |
4119 | 4119 |
4120 | 4120 |
| 4121 class DeferredSearchCache: public DeferredCode { |
| 4122 public: |
| 4123 DeferredSearchCache(Register dst, Register cache, Register key) |
| 4124 : dst_(dst), cache_(cache), key_(key) { |
| 4125 set_comment("[ DeferredSearchCache"); |
| 4126 } |
| 4127 |
| 4128 virtual void Generate(); |
| 4129 |
| 4130 private: |
| 4131 Register dst_, cache_, key_; |
| 4132 }; |
| 4133 |
| 4134 |
| 4135 void DeferredSearchCache::Generate() { |
| 4136 __ push(cache_); |
| 4137 __ push(key_); |
| 4138 __ CallRuntime(Runtime::kGetFromCache, 2); |
| 4139 if (!dst_.is(r0)) { |
| 4140 __ mov(dst_, r0); |
| 4141 } |
| 4142 } |
| 4143 |
| 4144 |
| 4145 void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) { |
| 4146 ASSERT_EQ(2, args->length()); |
| 4147 |
| 4148 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
| 4149 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); |
| 4150 |
| 4151 Handle<FixedArray> jsfunction_result_caches( |
| 4152 Top::global_context()->jsfunction_result_caches()); |
| 4153 if (jsfunction_result_caches->length() <= cache_id) { |
| 4154 __ Abort("Attempt to use undefined cache."); |
| 4155 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 4156 frame_->EmitPush(r0); |
| 4157 return; |
| 4158 } |
| 4159 Handle<FixedArray> cache_obj( |
| 4160 FixedArray::cast(jsfunction_result_caches->get(cache_id))); |
| 4161 |
| 4162 Load(args->at(1)); |
| 4163 frame_->EmitPop(r2); |
| 4164 |
| 4165 DeferredSearchCache* deferred = new DeferredSearchCache(r0, r1, r2); |
| 4166 |
| 4167 const int kFingerOffset = |
| 4168 FixedArray::OffsetOfElementAt(JSFunctionResultCache::kFingerIndex); |
| 4169 ASSERT(kSmiTag == 0 && kSmiTagSize == 1); |
| 4170 __ mov(r1, Operand(cache_obj)); |
| 4171 __ ldr(r0, FieldMemOperand(r1, kFingerOffset)); |
| 4172 // r0 now holds finger offset as a smi. |
| 4173 __ add(r3, r1, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 4174 // r3 now points to the start of fixed array elements. |
| 4175 __ ldr(r0, MemOperand(r3, r0, LSL, kPointerSizeLog2 - kSmiTagSize, PreIndex)); |
| 4176 // Note side effect of PreIndex: r3 now points to the key of the pair. |
| 4177 __ cmp(r2, r0); |
| 4178 deferred->Branch(ne); |
| 4179 |
| 4180 __ ldr(r0, MemOperand(r3, kPointerSize)); |
| 4181 |
| 4182 deferred->BindExit(); |
| 4183 frame_->EmitPush(r0); |
| 4184 } |
| 4185 |
| 4186 |
4121 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { | 4187 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { |
4122 ASSERT_EQ(args->length(), 1); | 4188 ASSERT_EQ(args->length(), 1); |
4123 | 4189 |
4124 // Load the argument on the stack and jump to the runtime. | 4190 // Load the argument on the stack and jump to the runtime. |
4125 Load(args->at(0)); | 4191 Load(args->at(0)); |
4126 | 4192 |
4127 NumberToStringStub stub; | 4193 NumberToStringStub stub; |
4128 frame_->CallStub(&stub, 1); | 4194 frame_->CallStub(&stub, 1); |
4129 frame_->EmitPush(r0); | 4195 frame_->EmitPush(r0); |
4130 } | 4196 } |
(...skipping 4700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8831 | 8897 |
8832 // Just jump to runtime to add the two strings. | 8898 // Just jump to runtime to add the two strings. |
8833 __ bind(&string_add_runtime); | 8899 __ bind(&string_add_runtime); |
8834 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); | 8900 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); |
8835 } | 8901 } |
8836 | 8902 |
8837 | 8903 |
8838 #undef __ | 8904 #undef __ |
8839 | 8905 |
8840 } } // namespace v8::internal | 8906 } } // namespace v8::internal |
OLD | NEW |