OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 } | 1278 } |
1279 | 1279 |
1280 if (s != NULL && s->is_eval_scope()) { | 1280 if (s != NULL && s->is_eval_scope()) { |
1281 // Loop up the context chain. There is no frame effect so it is | 1281 // Loop up the context chain. There is no frame effect so it is |
1282 // safe to use raw labels here. | 1282 // safe to use raw labels here. |
1283 Label next, fast; | 1283 Label next, fast; |
1284 if (!context.is(temp)) { | 1284 if (!context.is(temp)) { |
1285 __ movq(temp, context); | 1285 __ movq(temp, context); |
1286 } | 1286 } |
1287 // Load map for comparison into register, outside loop. | 1287 // Load map for comparison into register, outside loop. |
1288 __ LoadRoot(kScratchRegister, Heap::kGlobalContextMapRootIndex); | 1288 __ LoadRoot(kScratchRegister, Heap::kNativeContextMapRootIndex); |
1289 __ bind(&next); | 1289 __ bind(&next); |
1290 // Terminate at global context. | 1290 // Terminate at native context. |
1291 __ cmpq(kScratchRegister, FieldOperand(temp, HeapObject::kMapOffset)); | 1291 __ cmpq(kScratchRegister, FieldOperand(temp, HeapObject::kMapOffset)); |
1292 __ j(equal, &fast, Label::kNear); | 1292 __ j(equal, &fast, Label::kNear); |
1293 // Check that extension is NULL. | 1293 // Check that extension is NULL. |
1294 __ cmpq(ContextOperand(temp, Context::EXTENSION_INDEX), Immediate(0)); | 1294 __ cmpq(ContextOperand(temp, Context::EXTENSION_INDEX), Immediate(0)); |
1295 __ j(not_equal, slow); | 1295 __ j(not_equal, slow); |
1296 // Load next context in chain. | 1296 // Load next context in chain. |
1297 __ movq(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); | 1297 __ movq(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); |
1298 __ jmp(&next); | 1298 __ jmp(&next); |
1299 __ bind(&fast); | 1299 __ bind(&fast); |
1300 } | 1300 } |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2661 // Reload map as register rbx was used as temporary above. | 2661 // Reload map as register rbx was used as temporary above. |
2662 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); | 2662 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
2663 | 2663 |
2664 // If a valueOf property is not found on the object check that it's | 2664 // If a valueOf property is not found on the object check that it's |
2665 // prototype is the un-modified String prototype. If not result is false. | 2665 // prototype is the un-modified String prototype. If not result is false. |
2666 __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); | 2666 __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); |
2667 __ testq(rcx, Immediate(kSmiTagMask)); | 2667 __ testq(rcx, Immediate(kSmiTagMask)); |
2668 __ j(zero, if_false); | 2668 __ j(zero, if_false); |
2669 __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset)); | 2669 __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset)); |
2670 __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 2670 __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
2671 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalContextOffset)); | 2671 __ movq(rdx, FieldOperand(rdx, GlobalObject::kNativeContextOffset)); |
2672 __ cmpq(rcx, | 2672 __ cmpq(rcx, |
2673 ContextOperand(rdx, Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); | 2673 ContextOperand(rdx, Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); |
2674 __ j(not_equal, if_false); | 2674 __ j(not_equal, if_false); |
2675 // Set the bit in the map to indicate that it has been checked safe for | 2675 // Set the bit in the map to indicate that it has been checked safe for |
2676 // default valueOf and set true result. | 2676 // default valueOf and set true result. |
2677 __ or_(FieldOperand(rbx, Map::kBitField2Offset), | 2677 __ or_(FieldOperand(rbx, Map::kBitField2Offset), |
2678 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); | 2678 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
2679 __ jmp(if_true); | 2679 __ jmp(if_true); |
2680 | 2680 |
2681 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 2681 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2939 __ CallRuntime(Runtime::kNumberAlloc, 0); | 2939 __ CallRuntime(Runtime::kNumberAlloc, 0); |
2940 __ movq(rbx, rax); | 2940 __ movq(rbx, rax); |
2941 | 2941 |
2942 __ bind(&heapnumber_allocated); | 2942 __ bind(&heapnumber_allocated); |
2943 | 2943 |
2944 // Return a random uint32 number in rax. | 2944 // Return a random uint32 number in rax. |
2945 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs. | 2945 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs. |
2946 __ PrepareCallCFunction(1); | 2946 __ PrepareCallCFunction(1); |
2947 #ifdef _WIN64 | 2947 #ifdef _WIN64 |
2948 __ movq(rcx, ContextOperand(context_register(), Context::GLOBAL_INDEX)); | 2948 __ movq(rcx, ContextOperand(context_register(), Context::GLOBAL_INDEX)); |
2949 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalContextOffset)); | 2949 __ movq(rcx, FieldOperand(rcx, GlobalObject::kNativeContextOffset)); |
2950 | 2950 |
2951 #else | 2951 #else |
2952 __ movq(rdi, ContextOperand(context_register(), Context::GLOBAL_INDEX)); | 2952 __ movq(rdi, ContextOperand(context_register(), Context::GLOBAL_INDEX)); |
2953 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); | 2953 __ movq(rdi, FieldOperand(rdi, GlobalObject::kNativeContextOffset)); |
2954 #endif | 2954 #endif |
2955 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); | 2955 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); |
2956 | 2956 |
2957 // Convert 32 random bits in rax to 0.(32 random bits) in a double | 2957 // Convert 32 random bits in rax to 0.(32 random bits) in a double |
2958 // by computing: | 2958 // by computing: |
2959 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 2959 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
2960 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single. | 2960 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single. |
2961 __ movd(xmm1, rcx); | 2961 __ movd(xmm1, rcx); |
2962 __ movd(xmm0, rax); | 2962 __ movd(xmm0, rax); |
2963 __ cvtss2sd(xmm1, xmm1); | 2963 __ cvtss2sd(xmm1, xmm1); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3360 | 3360 |
3361 | 3361 |
3362 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { | 3362 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { |
3363 ZoneList<Expression*>* args = expr->arguments(); | 3363 ZoneList<Expression*>* args = expr->arguments(); |
3364 ASSERT_EQ(2, args->length()); | 3364 ASSERT_EQ(2, args->length()); |
3365 | 3365 |
3366 ASSERT_NE(NULL, args->at(0)->AsLiteral()); | 3366 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
3367 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); | 3367 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); |
3368 | 3368 |
3369 Handle<FixedArray> jsfunction_result_caches( | 3369 Handle<FixedArray> jsfunction_result_caches( |
3370 isolate()->global_context()->jsfunction_result_caches()); | 3370 isolate()->native_context()->jsfunction_result_caches()); |
3371 if (jsfunction_result_caches->length() <= cache_id) { | 3371 if (jsfunction_result_caches->length() <= cache_id) { |
3372 __ Abort("Attempt to use undefined cache."); | 3372 __ Abort("Attempt to use undefined cache."); |
3373 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 3373 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
3374 context()->Plug(rax); | 3374 context()->Plug(rax); |
3375 return; | 3375 return; |
3376 } | 3376 } |
3377 | 3377 |
3378 VisitForAccumulatorValue(args->at(1)); | 3378 VisitForAccumulatorValue(args->at(1)); |
3379 | 3379 |
3380 Register key = rax; | 3380 Register key = rax; |
3381 Register cache = rbx; | 3381 Register cache = rbx; |
3382 Register tmp = rcx; | 3382 Register tmp = rcx; |
3383 __ movq(cache, ContextOperand(rsi, Context::GLOBAL_INDEX)); | 3383 __ movq(cache, ContextOperand(rsi, Context::GLOBAL_INDEX)); |
3384 __ movq(cache, | 3384 __ movq(cache, |
3385 FieldOperand(cache, GlobalObject::kGlobalContextOffset)); | 3385 FieldOperand(cache, GlobalObject::kNativeContextOffset)); |
3386 __ movq(cache, | 3386 __ movq(cache, |
3387 ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX)); | 3387 ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX)); |
3388 __ movq(cache, | 3388 __ movq(cache, |
3389 FieldOperand(cache, FixedArray::OffsetOfElementAt(cache_id))); | 3389 FieldOperand(cache, FixedArray::OffsetOfElementAt(cache_id))); |
3390 | 3390 |
3391 Label done, not_found; | 3391 Label done, not_found; |
3392 // tmp now holds finger offset as a smi. | 3392 // tmp now holds finger offset as a smi. |
3393 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); | 3393 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); |
3394 __ movq(tmp, FieldOperand(cache, JSFunctionResultCache::kFingerOffset)); | 3394 __ movq(tmp, FieldOperand(cache, JSFunctionResultCache::kFingerOffset)); |
3395 SmiIndex index = | 3395 SmiIndex index = |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4422 | 4422 |
4423 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 4423 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
4424 __ movq(dst, ContextOperand(rsi, context_index)); | 4424 __ movq(dst, ContextOperand(rsi, context_index)); |
4425 } | 4425 } |
4426 | 4426 |
4427 | 4427 |
4428 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 4428 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
4429 Scope* declaration_scope = scope()->DeclarationScope(); | 4429 Scope* declaration_scope = scope()->DeclarationScope(); |
4430 if (declaration_scope->is_global_scope() || | 4430 if (declaration_scope->is_global_scope() || |
4431 declaration_scope->is_module_scope()) { | 4431 declaration_scope->is_module_scope()) { |
4432 // Contexts nested in the global context have a canonical empty function | 4432 // Contexts nested in the native context have a canonical empty function |
4433 // as their closure, not the anonymous closure containing the global | 4433 // as their closure, not the anonymous closure containing the global |
4434 // code. Pass a smi sentinel and let the runtime look up the empty | 4434 // code. Pass a smi sentinel and let the runtime look up the empty |
4435 // function. | 4435 // function. |
4436 __ Push(Smi::FromInt(0)); | 4436 __ Push(Smi::FromInt(0)); |
4437 } else if (declaration_scope->is_eval_scope()) { | 4437 } else if (declaration_scope->is_eval_scope()) { |
4438 // Contexts created by a call to eval have the same closure as the | 4438 // Contexts created by a call to eval have the same closure as the |
4439 // context calling eval, not the anonymous closure containing the eval | 4439 // context calling eval, not the anonymous closure containing the eval |
4440 // code. Fetch it from the context. | 4440 // code. Fetch it from the context. |
4441 __ push(ContextOperand(rsi, Context::CLOSURE_INDEX)); | 4441 __ push(ContextOperand(rsi, Context::CLOSURE_INDEX)); |
4442 } else { | 4442 } else { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4540 *context_length = 0; | 4540 *context_length = 0; |
4541 return previous_; | 4541 return previous_; |
4542 } | 4542 } |
4543 | 4543 |
4544 | 4544 |
4545 #undef __ | 4545 #undef __ |
4546 | 4546 |
4547 } } // namespace v8::internal | 4547 } } // namespace v8::internal |
4548 | 4548 |
4549 #endif // V8_TARGET_ARCH_X64 | 4549 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |