OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 4160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4171 VisitForStackValue(args->at(0)); | 4171 VisitForStackValue(args->at(0)); |
4172 VisitForStackValue(args->at(1)); | 4172 VisitForStackValue(args->at(1)); |
4173 VisitForAccumulatorValue(args->at(2)); | 4173 VisitForAccumulatorValue(args->at(2)); |
4174 __ Pop(rbx); | 4174 __ Pop(rbx); |
4175 __ Pop(rcx); | 4175 __ Pop(rcx); |
4176 __ CallStub(&stub); | 4176 __ CallStub(&stub); |
4177 context()->Plug(rax); | 4177 context()->Plug(rax); |
4178 } | 4178 } |
4179 | 4179 |
4180 | 4180 |
4181 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { | |
4182 ZoneList<Expression*>* args = expr->arguments(); | |
4183 DCHECK_EQ(2, args->length()); | |
4184 | |
4185 DCHECK_NOT_NULL(args->at(0)->AsLiteral()); | |
4186 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->value()))->value(); | |
4187 | |
4188 Handle<FixedArray> jsfunction_result_caches( | |
4189 isolate()->native_context()->jsfunction_result_caches()); | |
4190 if (jsfunction_result_caches->length() <= cache_id) { | |
4191 __ Abort(kAttemptToUseUndefinedCache); | |
4192 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | |
4193 context()->Plug(rax); | |
4194 return; | |
4195 } | |
4196 | |
4197 VisitForAccumulatorValue(args->at(1)); | |
4198 | |
4199 Register key = rax; | |
4200 Register cache = rbx; | |
4201 Register tmp = rcx; | |
4202 __ movp(cache, ContextOperand(rsi, Context::GLOBAL_OBJECT_INDEX)); | |
4203 __ movp(cache, | |
4204 FieldOperand(cache, GlobalObject::kNativeContextOffset)); | |
4205 __ movp(cache, | |
4206 ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX)); | |
4207 __ movp(cache, | |
4208 FieldOperand(cache, FixedArray::OffsetOfElementAt(cache_id))); | |
4209 | |
4210 Label done, not_found; | |
4211 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); | |
4212 __ movp(tmp, FieldOperand(cache, JSFunctionResultCache::kFingerOffset)); | |
4213 // tmp now holds finger offset as a smi. | |
4214 SmiIndex index = | |
4215 __ SmiToIndex(kScratchRegister, tmp, kPointerSizeLog2); | |
4216 __ cmpp(key, FieldOperand(cache, | |
4217 index.reg, | |
4218 index.scale, | |
4219 FixedArray::kHeaderSize)); | |
4220 __ j(not_equal, ¬_found, Label::kNear); | |
4221 __ movp(rax, FieldOperand(cache, | |
4222 index.reg, | |
4223 index.scale, | |
4224 FixedArray::kHeaderSize + kPointerSize)); | |
4225 __ jmp(&done, Label::kNear); | |
4226 | |
4227 __ bind(¬_found); | |
4228 // Call runtime to perform the lookup. | |
4229 __ Push(cache); | |
4230 __ Push(key); | |
4231 __ CallRuntime(Runtime::kGetFromCacheRT, 2); | |
4232 | |
4233 __ bind(&done); | |
4234 context()->Plug(rax); | |
4235 } | |
4236 | |
4237 | |
4238 void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) { | 4181 void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) { |
4239 ZoneList<Expression*>* args = expr->arguments(); | 4182 ZoneList<Expression*>* args = expr->arguments(); |
4240 DCHECK(args->length() == 1); | 4183 DCHECK(args->length() == 1); |
4241 | 4184 |
4242 VisitForAccumulatorValue(args->at(0)); | 4185 VisitForAccumulatorValue(args->at(0)); |
4243 | 4186 |
4244 Label materialize_true, materialize_false; | 4187 Label materialize_true, materialize_false; |
4245 Label* if_true = NULL; | 4188 Label* if_true = NULL; |
4246 Label* if_false = NULL; | 4189 Label* if_false = NULL; |
4247 Label* fall_through = NULL; | 4190 Label* fall_through = NULL; |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5412 Assembler::target_address_at(call_target_address, | 5355 Assembler::target_address_at(call_target_address, |
5413 unoptimized_code)); | 5356 unoptimized_code)); |
5414 return OSR_AFTER_STACK_CHECK; | 5357 return OSR_AFTER_STACK_CHECK; |
5415 } | 5358 } |
5416 | 5359 |
5417 | 5360 |
5418 } // namespace internal | 5361 } // namespace internal |
5419 } // namespace v8 | 5362 } // namespace v8 |
5420 | 5363 |
5421 #endif // V8_TARGET_ARCH_X64 | 5364 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |