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 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 876 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
877 __ j(equal, &exit); | 877 __ j(equal, &exit); |
878 Register null_value = rdi; | 878 Register null_value = rdi; |
879 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 879 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
880 __ cmpq(rax, null_value); | 880 __ cmpq(rax, null_value); |
881 __ j(equal, &exit); | 881 __ j(equal, &exit); |
882 | 882 |
883 // Convert the object to a JS object. | 883 // Convert the object to a JS object. |
884 Label convert, done_convert; | 884 Label convert, done_convert; |
885 __ JumpIfSmi(rax, &convert); | 885 __ JumpIfSmi(rax, &convert); |
886 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx); | 886 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx); |
887 __ j(above_equal, &done_convert); | 887 __ j(above_equal, &done_convert); |
888 __ bind(&convert); | 888 __ bind(&convert); |
889 __ push(rax); | 889 __ push(rax); |
890 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 890 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
891 __ bind(&done_convert); | 891 __ bind(&done_convert); |
892 __ push(rax); | 892 __ push(rax); |
893 | 893 |
894 // Check cache validity in generated code. This is a fast case for | 894 // Check cache validity in generated code. This is a fast case for |
895 // the JSObject::IsSimpleEnum cache validity checks. If we cannot | 895 // the JSObject::IsSimpleEnum cache validity checks. If we cannot |
896 // guarantee cache validity, call the runtime system to check cache | 896 // guarantee cache validity, call the runtime system to check cache |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 | 2371 |
2372 __ JumpIfSmi(rax, if_false); | 2372 __ JumpIfSmi(rax, if_false); |
2373 __ CompareRoot(rax, Heap::kNullValueRootIndex); | 2373 __ CompareRoot(rax, Heap::kNullValueRootIndex); |
2374 __ j(equal, if_true); | 2374 __ j(equal, if_true); |
2375 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); | 2375 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
2376 // Undetectable objects behave like undefined when tested with typeof. | 2376 // Undetectable objects behave like undefined when tested with typeof. |
2377 __ testb(FieldOperand(rbx, Map::kBitFieldOffset), | 2377 __ testb(FieldOperand(rbx, Map::kBitFieldOffset), |
2378 Immediate(1 << Map::kIsUndetectable)); | 2378 Immediate(1 << Map::kIsUndetectable)); |
2379 __ j(not_zero, if_false); | 2379 __ j(not_zero, if_false); |
2380 __ movzxbq(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset)); | 2380 __ movzxbq(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset)); |
2381 __ cmpq(rbx, Immediate(FIRST_JS_OBJECT_TYPE)); | 2381 __ cmpq(rbx, Immediate(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
2382 __ j(below, if_false); | 2382 __ j(below, if_false); |
2383 __ cmpq(rbx, Immediate(LAST_JS_OBJECT_TYPE)); | 2383 __ cmpq(rbx, Immediate(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
2384 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 2384 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
2385 Split(below_equal, if_true, if_false, fall_through); | 2385 Split(below_equal, if_true, if_false, fall_through); |
2386 | 2386 |
2387 context()->Plug(if_true, if_false); | 2387 context()->Plug(if_true, if_false); |
2388 } | 2388 } |
2389 | 2389 |
2390 | 2390 |
2391 void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) { | 2391 void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) { |
2392 ASSERT(args->length() == 1); | 2392 ASSERT(args->length() == 1); |
2393 | 2393 |
2394 VisitForAccumulatorValue(args->at(0)); | 2394 VisitForAccumulatorValue(args->at(0)); |
2395 | 2395 |
2396 Label materialize_true, materialize_false; | 2396 Label materialize_true, materialize_false; |
2397 Label* if_true = NULL; | 2397 Label* if_true = NULL; |
2398 Label* if_false = NULL; | 2398 Label* if_false = NULL; |
2399 Label* fall_through = NULL; | 2399 Label* fall_through = NULL; |
2400 context()->PrepareTest(&materialize_true, &materialize_false, | 2400 context()->PrepareTest(&materialize_true, &materialize_false, |
2401 &if_true, &if_false, &fall_through); | 2401 &if_true, &if_false, &fall_through); |
2402 | 2402 |
2403 __ JumpIfSmi(rax, if_false); | 2403 __ JumpIfSmi(rax, if_false); |
2404 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rbx); | 2404 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rbx); |
2405 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 2405 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
2406 Split(above_equal, if_true, if_false, fall_through); | 2406 Split(above_equal, if_true, if_false, fall_through); |
2407 | 2407 |
2408 context()->Plug(if_true, if_false); | 2408 context()->Plug(if_true, if_false); |
2409 } | 2409 } |
2410 | 2410 |
2411 | 2411 |
2412 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) { | 2412 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) { |
2413 ASSERT(args->length() == 1); | 2413 ASSERT(args->length() == 1); |
2414 | 2414 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2673 ASSERT(args->length() == 1); | 2673 ASSERT(args->length() == 1); |
2674 Label done, null, function, non_function_constructor; | 2674 Label done, null, function, non_function_constructor; |
2675 | 2675 |
2676 VisitForAccumulatorValue(args->at(0)); | 2676 VisitForAccumulatorValue(args->at(0)); |
2677 | 2677 |
2678 // If the object is a smi, we return null. | 2678 // If the object is a smi, we return null. |
2679 __ JumpIfSmi(rax, &null); | 2679 __ JumpIfSmi(rax, &null); |
2680 | 2680 |
2681 // Check that the object is a JS object but take special care of JS | 2681 // Check that the object is a JS object but take special care of JS |
2682 // functions to make sure they have 'Function' as their class. | 2682 // functions to make sure they have 'Function' as their class. |
2683 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rax); // Map is now in rax. | 2683 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rax); |
| 2684 // Map is now in rax. |
2684 __ j(below, &null); | 2685 __ j(below, &null); |
2685 | 2686 |
2686 // As long as JS_FUNCTION_TYPE is the last instance type and it is | 2687 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type, and |
2687 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for | 2688 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after |
2688 // LAST_JS_OBJECT_TYPE. | 2689 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. |
2689 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 2690 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); |
2690 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); | 2691 STATIC_ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == |
2691 __ CmpInstanceType(rax, JS_FUNCTION_TYPE); | 2692 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); |
2692 __ j(equal, &function); | 2693 __ CmpInstanceType(rax, FIRST_CALLABLE_SPEC_OBJECT_TYPE); |
| 2694 __ j(above_equal, &function); |
2693 | 2695 |
2694 // Check if the constructor in the map is a function. | 2696 // Check if the constructor in the map is a function. |
2695 __ movq(rax, FieldOperand(rax, Map::kConstructorOffset)); | 2697 __ movq(rax, FieldOperand(rax, Map::kConstructorOffset)); |
2696 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx); | 2698 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx); |
2697 __ j(not_equal, &non_function_constructor); | 2699 __ j(not_equal, &non_function_constructor); |
2698 | 2700 |
2699 // rax now contains the constructor function. Grab the | 2701 // rax now contains the constructor function. Grab the |
2700 // instance class name from there. | 2702 // instance class name from there. |
2701 __ movq(rax, FieldOperand(rax, JSFunction::kSharedFunctionInfoOffset)); | 2703 __ movq(rax, FieldOperand(rax, JSFunction::kSharedFunctionInfoOffset)); |
2702 __ movq(rax, FieldOperand(rax, SharedFunctionInfo::kInstanceClassNameOffset)); | 2704 __ movq(rax, FieldOperand(rax, SharedFunctionInfo::kInstanceClassNameOffset)); |
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4032 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 4034 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
4033 __ j(equal, if_true); | 4035 __ j(equal, if_true); |
4034 __ JumpIfSmi(rax, if_false); | 4036 __ JumpIfSmi(rax, if_false); |
4035 // Check for undetectable objects => true. | 4037 // Check for undetectable objects => true. |
4036 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); | 4038 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); |
4037 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 4039 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
4038 Immediate(1 << Map::kIsUndetectable)); | 4040 Immediate(1 << Map::kIsUndetectable)); |
4039 Split(not_zero, if_true, if_false, fall_through); | 4041 Split(not_zero, if_true, if_false, fall_through); |
4040 } else if (check->Equals(isolate()->heap()->function_symbol())) { | 4042 } else if (check->Equals(isolate()->heap()->function_symbol())) { |
4041 __ JumpIfSmi(rax, if_false); | 4043 __ JumpIfSmi(rax, if_false); |
4042 __ CmpObjectType(rax, FIRST_FUNCTION_CLASS_TYPE, rdx); | 4044 STATIC_ASSERT(LAST_CALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE); |
| 4045 __ CmpObjectType(rax, FIRST_CALLABLE_SPEC_OBJECT_TYPE, rdx); |
4043 Split(above_equal, if_true, if_false, fall_through); | 4046 Split(above_equal, if_true, if_false, fall_through); |
4044 } else if (check->Equals(isolate()->heap()->object_symbol())) { | 4047 } else if (check->Equals(isolate()->heap()->object_symbol())) { |
4045 __ JumpIfSmi(rax, if_false); | 4048 __ JumpIfSmi(rax, if_false); |
4046 __ CompareRoot(rax, Heap::kNullValueRootIndex); | 4049 __ CompareRoot(rax, Heap::kNullValueRootIndex); |
4047 __ j(equal, if_true); | 4050 __ j(equal, if_true); |
4048 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rdx); | 4051 __ CmpObjectType(rax, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, rdx); |
4049 __ j(below, if_false); | 4052 __ j(below, if_false); |
4050 __ CmpInstanceType(rdx, FIRST_FUNCTION_CLASS_TYPE); | 4053 __ CmpInstanceType(rdx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
4051 __ j(above_equal, if_false); | 4054 __ j(above, if_false); |
4052 // Check for undetectable objects => false. | 4055 // Check for undetectable objects => false. |
4053 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 4056 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
4054 Immediate(1 << Map::kIsUndetectable)); | 4057 Immediate(1 << Map::kIsUndetectable)); |
4055 Split(zero, if_true, if_false, fall_through); | 4058 Split(zero, if_true, if_false, fall_through); |
4056 } else { | 4059 } else { |
4057 if (if_false != fall_through) __ jmp(if_false); | 4060 if (if_false != fall_through) __ jmp(if_false); |
4058 } | 4061 } |
4059 | 4062 |
4060 return true; | 4063 return true; |
4061 } | 4064 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4315 __ ret(0); | 4318 __ ret(0); |
4316 } | 4319 } |
4317 | 4320 |
4318 | 4321 |
4319 #undef __ | 4322 #undef __ |
4320 | 4323 |
4321 | 4324 |
4322 } } // namespace v8::internal | 4325 } } // namespace v8::internal |
4323 | 4326 |
4324 #endif // V8_TARGET_ARCH_X64 | 4327 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |