| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 VisitForAccumulatorValue(stmt->enumerable()); | 854 VisitForAccumulatorValue(stmt->enumerable()); |
| 855 __ cmp(eax, isolate()->factory()->undefined_value()); | 855 __ cmp(eax, isolate()->factory()->undefined_value()); |
| 856 __ j(equal, &exit); | 856 __ j(equal, &exit); |
| 857 __ cmp(eax, isolate()->factory()->null_value()); | 857 __ cmp(eax, isolate()->factory()->null_value()); |
| 858 __ j(equal, &exit); | 858 __ j(equal, &exit); |
| 859 | 859 |
| 860 // Convert the object to a JS object. | 860 // Convert the object to a JS object. |
| 861 Label convert, done_convert; | 861 Label convert, done_convert; |
| 862 __ test(eax, Immediate(kSmiTagMask)); | 862 __ test(eax, Immediate(kSmiTagMask)); |
| 863 __ j(zero, &convert, Label::kNear); | 863 __ j(zero, &convert, Label::kNear); |
| 864 __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, ecx); | 864 __ CmpObjectType(eax, FIRST_OBJECT_OR_FUNCTION_CLASS_TYPE, ecx); |
| 865 __ j(above_equal, &done_convert, Label::kNear); | 865 __ j(above_equal, &done_convert, Label::kNear); |
| 866 __ bind(&convert); | 866 __ bind(&convert); |
| 867 __ push(eax); | 867 __ push(eax); |
| 868 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 868 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
| 869 __ bind(&done_convert); | 869 __ bind(&done_convert); |
| 870 __ push(eax); | 870 __ push(eax); |
| 871 | 871 |
| 872 // Check cache validity in generated code. This is a fast case for | 872 // Check cache validity in generated code. This is a fast case for |
| 873 // the JSObject::IsSimpleEnum cache validity checks. If we cannot | 873 // the JSObject::IsSimpleEnum cache validity checks. If we cannot |
| 874 // guarantee cache validity, call the runtime system to check cache | 874 // guarantee cache validity, call the runtime system to check cache |
| (...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2378 __ test(eax, Immediate(kSmiTagMask)); | 2378 __ test(eax, Immediate(kSmiTagMask)); |
| 2379 __ j(zero, if_false); | 2379 __ j(zero, if_false); |
| 2380 __ cmp(eax, isolate()->factory()->null_value()); | 2380 __ cmp(eax, isolate()->factory()->null_value()); |
| 2381 __ j(equal, if_true); | 2381 __ j(equal, if_true); |
| 2382 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 2382 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 2383 // Undetectable objects behave like undefined when tested with typeof. | 2383 // Undetectable objects behave like undefined when tested with typeof. |
| 2384 __ movzx_b(ecx, FieldOperand(ebx, Map::kBitFieldOffset)); | 2384 __ movzx_b(ecx, FieldOperand(ebx, Map::kBitFieldOffset)); |
| 2385 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); | 2385 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); |
| 2386 __ j(not_zero, if_false); | 2386 __ j(not_zero, if_false); |
| 2387 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | 2387 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
| 2388 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); | 2388 __ cmp(ecx, FIRST_OBJECT_CLASS_TYPE); |
| 2389 __ j(below, if_false); | 2389 __ j(below, if_false); |
| 2390 __ cmp(ecx, LAST_JS_OBJECT_TYPE); | 2390 __ cmp(ecx, LAST_OBJECT_CLASS_TYPE); |
| 2391 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 2391 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 2392 Split(below_equal, if_true, if_false, fall_through); | 2392 Split(below_equal, if_true, if_false, fall_through); |
| 2393 | 2393 |
| 2394 context()->Plug(if_true, if_false); | 2394 context()->Plug(if_true, if_false); |
| 2395 } | 2395 } |
| 2396 | 2396 |
| 2397 | 2397 |
| 2398 void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) { | 2398 void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) { |
| 2399 ASSERT(args->length() == 1); | 2399 ASSERT(args->length() == 1); |
| 2400 | 2400 |
| 2401 VisitForAccumulatorValue(args->at(0)); | 2401 VisitForAccumulatorValue(args->at(0)); |
| 2402 | 2402 |
| 2403 Label materialize_true, materialize_false; | 2403 Label materialize_true, materialize_false; |
| 2404 Label* if_true = NULL; | 2404 Label* if_true = NULL; |
| 2405 Label* if_false = NULL; | 2405 Label* if_false = NULL; |
| 2406 Label* fall_through = NULL; | 2406 Label* fall_through = NULL; |
| 2407 context()->PrepareTest(&materialize_true, &materialize_false, | 2407 context()->PrepareTest(&materialize_true, &materialize_false, |
| 2408 &if_true, &if_false, &fall_through); | 2408 &if_true, &if_false, &fall_through); |
| 2409 | 2409 |
| 2410 __ test(eax, Immediate(kSmiTagMask)); | 2410 __ test(eax, Immediate(kSmiTagMask)); |
| 2411 __ j(equal, if_false); | 2411 __ j(equal, if_false); |
| 2412 __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, ebx); | 2412 __ CmpObjectType(eax, FIRST_OBJECT_OR_FUNCTION_CLASS_TYPE, ebx); |
| 2413 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 2413 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 2414 Split(above_equal, if_true, if_false, fall_through); | 2414 Split(above_equal, if_true, if_false, fall_through); |
| 2415 | 2415 |
| 2416 context()->Plug(if_true, if_false); | 2416 context()->Plug(if_true, if_false); |
| 2417 } | 2417 } |
| 2418 | 2418 |
| 2419 | 2419 |
| 2420 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) { | 2420 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) { |
| 2421 ASSERT(args->length() == 1); | 2421 ASSERT(args->length() == 1); |
| 2422 | 2422 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2688 Label done, null, function, non_function_constructor; | 2688 Label done, null, function, non_function_constructor; |
| 2689 | 2689 |
| 2690 VisitForAccumulatorValue(args->at(0)); | 2690 VisitForAccumulatorValue(args->at(0)); |
| 2691 | 2691 |
| 2692 // If the object is a smi, we return null. | 2692 // If the object is a smi, we return null. |
| 2693 __ test(eax, Immediate(kSmiTagMask)); | 2693 __ test(eax, Immediate(kSmiTagMask)); |
| 2694 __ j(zero, &null); | 2694 __ j(zero, &null); |
| 2695 | 2695 |
| 2696 // Check that the object is a JS object but take special care of JS | 2696 // Check that the object is a JS object but take special care of JS |
| 2697 // functions to make sure they have 'Function' as their class. | 2697 // functions to make sure they have 'Function' as their class. |
| 2698 __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, eax); // Map is now in eax. | 2698 __ CmpObjectType(eax, FIRST_OBJECT_OR_FUNCTION_CLASS_TYPE, eax); |
| 2699 // Map is now in eax. |
| 2699 __ j(below, &null); | 2700 __ j(below, &null); |
| 2700 | 2701 |
| 2701 // As long as JS_FUNCTION_TYPE is the last instance type and it is | 2702 // As long as LAST_FUNCTION_CLASS_TYPE is the last instance type, and |
| 2702 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for | 2703 // FIRST_FUNCTION_CLASS_TYPE comes right after LAST_OBJECT_CLASS_TYPE, |
| 2703 // LAST_JS_OBJECT_TYPE. | 2704 // we can avoid checking for LAST_OBJECT_CLASS_TYPE. |
| 2704 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 2705 ASSERT(LAST_TYPE == LAST_FUNCTION_CLASS_TYPE); |
| 2705 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); | 2706 ASSERT(FIRST_FUNCTION_CLASS_TYPE == LAST_OBJECT_CLASS_TYPE + 1); |
| 2706 __ CmpInstanceType(eax, JS_FUNCTION_TYPE); | 2707 __ CmpInstanceType(eax, FIRST_FUNCTION_CLASS_TYPE); |
| 2707 __ j(equal, &function); | 2708 __ j(above_equal, &function); |
| 2708 | 2709 |
| 2709 // Check if the constructor in the map is a function. | 2710 // Check if the constructor in the map is a function. |
| 2710 __ mov(eax, FieldOperand(eax, Map::kConstructorOffset)); | 2711 __ mov(eax, FieldOperand(eax, Map::kConstructorOffset)); |
| 2711 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); | 2712 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); |
| 2712 __ j(not_equal, &non_function_constructor); | 2713 __ j(not_equal, &non_function_constructor); |
| 2713 | 2714 |
| 2714 // eax now contains the constructor function. Grab the | 2715 // eax now contains the constructor function. Grab the |
| 2715 // instance class name from there. | 2716 // instance class name from there. |
| 2716 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset)); | 2717 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset)); |
| 2717 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kInstanceClassNameOffset)); | 2718 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kInstanceClassNameOffset)); |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4042 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); | 4043 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); |
| 4043 Split(not_zero, if_true, if_false, fall_through); | 4044 Split(not_zero, if_true, if_false, fall_through); |
| 4044 } else if (check->Equals(isolate()->heap()->function_symbol())) { | 4045 } else if (check->Equals(isolate()->heap()->function_symbol())) { |
| 4045 __ JumpIfSmi(eax, if_false); | 4046 __ JumpIfSmi(eax, if_false); |
| 4046 __ CmpObjectType(eax, FIRST_FUNCTION_CLASS_TYPE, edx); | 4047 __ CmpObjectType(eax, FIRST_FUNCTION_CLASS_TYPE, edx); |
| 4047 Split(above_equal, if_true, if_false, fall_through); | 4048 Split(above_equal, if_true, if_false, fall_through); |
| 4048 } else if (check->Equals(isolate()->heap()->object_symbol())) { | 4049 } else if (check->Equals(isolate()->heap()->object_symbol())) { |
| 4049 __ JumpIfSmi(eax, if_false); | 4050 __ JumpIfSmi(eax, if_false); |
| 4050 __ cmp(eax, isolate()->factory()->null_value()); | 4051 __ cmp(eax, isolate()->factory()->null_value()); |
| 4051 __ j(equal, if_true); | 4052 __ j(equal, if_true); |
| 4052 __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, edx); | 4053 __ CmpObjectType(eax, FIRST_OBJECT_CLASS_TYPE, edx); |
| 4053 __ j(below, if_false); | 4054 __ j(below, if_false); |
| 4054 __ CmpInstanceType(edx, FIRST_FUNCTION_CLASS_TYPE); | 4055 __ CmpInstanceType(edx, LAST_OBJECT_CLASS_TYPE); |
| 4055 __ j(above_equal, if_false); | 4056 __ j(above, if_false); |
| 4056 // Check for undetectable objects => false. | 4057 // Check for undetectable objects => false. |
| 4057 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), | 4058 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), |
| 4058 1 << Map::kIsUndetectable); | 4059 1 << Map::kIsUndetectable); |
| 4059 Split(zero, if_true, if_false, fall_through); | 4060 Split(zero, if_true, if_false, fall_through); |
| 4060 } else { | 4061 } else { |
| 4061 if (if_false != fall_through) __ jmp(if_false); | 4062 if (if_false != fall_through) __ jmp(if_false); |
| 4062 } | 4063 } |
| 4063 | 4064 |
| 4064 return true; | 4065 return true; |
| 4065 } | 4066 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4315 // And return. | 4316 // And return. |
| 4316 __ ret(0); | 4317 __ ret(0); |
| 4317 } | 4318 } |
| 4318 | 4319 |
| 4319 | 4320 |
| 4320 #undef __ | 4321 #undef __ |
| 4321 | 4322 |
| 4322 } } // namespace v8::internal | 4323 } } // namespace v8::internal |
| 4323 | 4324 |
| 4324 #endif // V8_TARGET_ARCH_IA32 | 4325 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |