| 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 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 if (s != NULL && s->is_eval_scope()) { | 1260 if (s != NULL && s->is_eval_scope()) { |
| 1261 // Loop up the context chain. There is no frame effect so it is | 1261 // Loop up the context chain. There is no frame effect so it is |
| 1262 // safe to use raw labels here. | 1262 // safe to use raw labels here. |
| 1263 Label next, fast; | 1263 Label next, fast; |
| 1264 if (!context.is(temp)) { | 1264 if (!context.is(temp)) { |
| 1265 __ mov(temp, context); | 1265 __ mov(temp, context); |
| 1266 } | 1266 } |
| 1267 __ bind(&next); | 1267 __ bind(&next); |
| 1268 // Terminate at native context. | 1268 // Terminate at global context. |
| 1269 __ cmp(FieldOperand(temp, HeapObject::kMapOffset), | 1269 __ cmp(FieldOperand(temp, HeapObject::kMapOffset), |
| 1270 Immediate(isolate()->factory()->native_context_map())); | 1270 Immediate(isolate()->factory()->global_context_map())); |
| 1271 __ j(equal, &fast, Label::kNear); | 1271 __ j(equal, &fast, Label::kNear); |
| 1272 // Check that extension is NULL. | 1272 // Check that extension is NULL. |
| 1273 __ cmp(ContextOperand(temp, Context::EXTENSION_INDEX), Immediate(0)); | 1273 __ cmp(ContextOperand(temp, Context::EXTENSION_INDEX), Immediate(0)); |
| 1274 __ j(not_equal, slow); | 1274 __ j(not_equal, slow); |
| 1275 // Load next context in chain. | 1275 // Load next context in chain. |
| 1276 __ mov(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); | 1276 __ mov(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); |
| 1277 __ jmp(&next); | 1277 __ jmp(&next); |
| 1278 __ bind(&fast); | 1278 __ bind(&fast); |
| 1279 } | 1279 } |
| 1280 | 1280 |
| (...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2687 __ j(not_equal, &loop); | 2687 __ j(not_equal, &loop); |
| 2688 | 2688 |
| 2689 // Reload map as register ebx was used as temporary above. | 2689 // Reload map as register ebx was used as temporary above. |
| 2690 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 2690 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 2691 | 2691 |
| 2692 // If a valueOf property is not found on the object check that it's | 2692 // If a valueOf property is not found on the object check that it's |
| 2693 // prototype is the un-modified String prototype. If not result is false. | 2693 // prototype is the un-modified String prototype. If not result is false. |
| 2694 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | 2694 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); |
| 2695 __ JumpIfSmi(ecx, if_false); | 2695 __ JumpIfSmi(ecx, if_false); |
| 2696 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); | 2696 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); |
| 2697 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 2697 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 2698 __ mov(edx, | 2698 __ mov(edx, |
| 2699 FieldOperand(edx, GlobalObject::kNativeContextOffset)); | 2699 FieldOperand(edx, GlobalObject::kGlobalContextOffset)); |
| 2700 __ cmp(ecx, | 2700 __ cmp(ecx, |
| 2701 ContextOperand(edx, | 2701 ContextOperand(edx, |
| 2702 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); | 2702 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); |
| 2703 __ j(not_equal, if_false); | 2703 __ j(not_equal, if_false); |
| 2704 // Set the bit in the map to indicate that it has been checked safe for | 2704 // Set the bit in the map to indicate that it has been checked safe for |
| 2705 // default valueOf and set true result. | 2705 // default valueOf and set true result. |
| 2706 __ or_(FieldOperand(ebx, Map::kBitField2Offset), | 2706 __ or_(FieldOperand(ebx, Map::kBitField2Offset), |
| 2707 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); | 2707 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
| 2708 __ jmp(if_true); | 2708 __ jmp(if_true); |
| 2709 | 2709 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2964 __ jmp(&heapnumber_allocated); | 2964 __ jmp(&heapnumber_allocated); |
| 2965 | 2965 |
| 2966 __ bind(&slow_allocate_heapnumber); | 2966 __ bind(&slow_allocate_heapnumber); |
| 2967 // Allocate a heap number. | 2967 // Allocate a heap number. |
| 2968 __ CallRuntime(Runtime::kNumberAlloc, 0); | 2968 __ CallRuntime(Runtime::kNumberAlloc, 0); |
| 2969 __ mov(edi, eax); | 2969 __ mov(edi, eax); |
| 2970 | 2970 |
| 2971 __ bind(&heapnumber_allocated); | 2971 __ bind(&heapnumber_allocated); |
| 2972 | 2972 |
| 2973 __ PrepareCallCFunction(1, ebx); | 2973 __ PrepareCallCFunction(1, ebx); |
| 2974 __ mov(eax, ContextOperand(context_register(), Context::GLOBAL_OBJECT_INDEX)); | 2974 __ mov(eax, ContextOperand(context_register(), Context::GLOBAL_INDEX)); |
| 2975 __ mov(eax, FieldOperand(eax, GlobalObject::kNativeContextOffset)); | 2975 __ mov(eax, FieldOperand(eax, GlobalObject::kGlobalContextOffset)); |
| 2976 __ mov(Operand(esp, 0), eax); | 2976 __ mov(Operand(esp, 0), eax); |
| 2977 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); | 2977 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); |
| 2978 | 2978 |
| 2979 // Convert 32 random bits in eax to 0.(32 random bits) in a double | 2979 // Convert 32 random bits in eax to 0.(32 random bits) in a double |
| 2980 // by computing: | 2980 // by computing: |
| 2981 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 2981 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
| 2982 // This is implemented on both SSE2 and FPU. | 2982 // This is implemented on both SSE2 and FPU. |
| 2983 if (CpuFeatures::IsSupported(SSE2)) { | 2983 if (CpuFeatures::IsSupported(SSE2)) { |
| 2984 CpuFeatures::Scope fscope(SSE2); | 2984 CpuFeatures::Scope fscope(SSE2); |
| 2985 __ mov(ebx, Immediate(0x49800000)); // 1.0 x 2^20 as single. | 2985 __ mov(ebx, Immediate(0x49800000)); // 1.0 x 2^20 as single. |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3396 | 3396 |
| 3397 | 3397 |
| 3398 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { | 3398 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { |
| 3399 ZoneList<Expression*>* args = expr->arguments(); | 3399 ZoneList<Expression*>* args = expr->arguments(); |
| 3400 ASSERT_EQ(2, args->length()); | 3400 ASSERT_EQ(2, args->length()); |
| 3401 | 3401 |
| 3402 ASSERT_NE(NULL, args->at(0)->AsLiteral()); | 3402 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
| 3403 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); | 3403 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); |
| 3404 | 3404 |
| 3405 Handle<FixedArray> jsfunction_result_caches( | 3405 Handle<FixedArray> jsfunction_result_caches( |
| 3406 isolate()->native_context()->jsfunction_result_caches()); | 3406 isolate()->global_context()->jsfunction_result_caches()); |
| 3407 if (jsfunction_result_caches->length() <= cache_id) { | 3407 if (jsfunction_result_caches->length() <= cache_id) { |
| 3408 __ Abort("Attempt to use undefined cache."); | 3408 __ Abort("Attempt to use undefined cache."); |
| 3409 __ mov(eax, isolate()->factory()->undefined_value()); | 3409 __ mov(eax, isolate()->factory()->undefined_value()); |
| 3410 context()->Plug(eax); | 3410 context()->Plug(eax); |
| 3411 return; | 3411 return; |
| 3412 } | 3412 } |
| 3413 | 3413 |
| 3414 VisitForAccumulatorValue(args->at(1)); | 3414 VisitForAccumulatorValue(args->at(1)); |
| 3415 | 3415 |
| 3416 Register key = eax; | 3416 Register key = eax; |
| 3417 Register cache = ebx; | 3417 Register cache = ebx; |
| 3418 Register tmp = ecx; | 3418 Register tmp = ecx; |
| 3419 __ mov(cache, ContextOperand(esi, Context::GLOBAL_OBJECT_INDEX)); | 3419 __ mov(cache, ContextOperand(esi, Context::GLOBAL_INDEX)); |
| 3420 __ mov(cache, | 3420 __ mov(cache, |
| 3421 FieldOperand(cache, GlobalObject::kNativeContextOffset)); | 3421 FieldOperand(cache, GlobalObject::kGlobalContextOffset)); |
| 3422 __ mov(cache, ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX)); | 3422 __ mov(cache, ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX)); |
| 3423 __ mov(cache, | 3423 __ mov(cache, |
| 3424 FieldOperand(cache, FixedArray::OffsetOfElementAt(cache_id))); | 3424 FieldOperand(cache, FixedArray::OffsetOfElementAt(cache_id))); |
| 3425 | 3425 |
| 3426 Label done, not_found; | 3426 Label done, not_found; |
| 3427 // tmp now holds finger offset as a smi. | 3427 // tmp now holds finger offset as a smi. |
| 3428 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); | 3428 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); |
| 3429 __ mov(tmp, FieldOperand(cache, JSFunctionResultCache::kFingerOffset)); | 3429 __ mov(tmp, FieldOperand(cache, JSFunctionResultCache::kFingerOffset)); |
| 3430 __ cmp(key, CodeGenerator::FixedArrayElementOperand(cache, tmp)); | 3430 __ cmp(key, CodeGenerator::FixedArrayElementOperand(cache, tmp)); |
| 3431 __ j(not_equal, ¬_found); | 3431 __ j(not_equal, ¬_found); |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4431 | 4431 |
| 4432 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 4432 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
| 4433 __ mov(dst, ContextOperand(esi, context_index)); | 4433 __ mov(dst, ContextOperand(esi, context_index)); |
| 4434 } | 4434 } |
| 4435 | 4435 |
| 4436 | 4436 |
| 4437 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 4437 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
| 4438 Scope* declaration_scope = scope()->DeclarationScope(); | 4438 Scope* declaration_scope = scope()->DeclarationScope(); |
| 4439 if (declaration_scope->is_global_scope() || | 4439 if (declaration_scope->is_global_scope() || |
| 4440 declaration_scope->is_module_scope()) { | 4440 declaration_scope->is_module_scope()) { |
| 4441 // Contexts nested in the native context have a canonical empty function | 4441 // Contexts nested in the global context have a canonical empty function |
| 4442 // as their closure, not the anonymous closure containing the global | 4442 // as their closure, not the anonymous closure containing the global |
| 4443 // code. Pass a smi sentinel and let the runtime look up the empty | 4443 // code. Pass a smi sentinel and let the runtime look up the empty |
| 4444 // function. | 4444 // function. |
| 4445 __ push(Immediate(Smi::FromInt(0))); | 4445 __ push(Immediate(Smi::FromInt(0))); |
| 4446 } else if (declaration_scope->is_eval_scope()) { | 4446 } else if (declaration_scope->is_eval_scope()) { |
| 4447 // Contexts nested inside eval code have the same closure as the context | 4447 // Contexts nested inside eval code have the same closure as the context |
| 4448 // calling eval, not the anonymous closure containing the eval code. | 4448 // calling eval, not the anonymous closure containing the eval code. |
| 4449 // Fetch it from the context. | 4449 // Fetch it from the context. |
| 4450 __ push(ContextOperand(esi, Context::CLOSURE_INDEX)); | 4450 __ push(ContextOperand(esi, Context::CLOSURE_INDEX)); |
| 4451 } else { | 4451 } else { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4545 *stack_depth = 0; | 4545 *stack_depth = 0; |
| 4546 *context_length = 0; | 4546 *context_length = 0; |
| 4547 return previous_; | 4547 return previous_; |
| 4548 } | 4548 } |
| 4549 | 4549 |
| 4550 #undef __ | 4550 #undef __ |
| 4551 | 4551 |
| 4552 } } // namespace v8::internal | 4552 } } // namespace v8::internal |
| 4553 | 4553 |
| 4554 #endif // V8_TARGET_ARCH_IA32 | 4554 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |