| 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 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3110 | 3110 |
| 3111 VisitForAccumulatorValue(args->at(0)); | 3111 VisitForAccumulatorValue(args->at(0)); |
| 3112 | 3112 |
| 3113 Label materialize_true, materialize_false; | 3113 Label materialize_true, materialize_false; |
| 3114 Label* if_true = NULL; | 3114 Label* if_true = NULL; |
| 3115 Label* if_false = NULL; | 3115 Label* if_false = NULL; |
| 3116 Label* fall_through = NULL; | 3116 Label* fall_through = NULL; |
| 3117 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, | 3117 context()->PrepareTest(&materialize_true, &materialize_false, &if_true, |
| 3118 &if_false, &fall_through); | 3118 &if_false, &fall_through); |
| 3119 | 3119 |
| 3120 | |
| 3121 __ JumpIfSmi(eax, if_false); | 3120 __ JumpIfSmi(eax, if_false); |
| 3122 __ CmpObjectType(eax, JS_PROXY_TYPE, ebx); | 3121 __ CmpObjectType(eax, JS_PROXY_TYPE, ebx); |
| 3123 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3122 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
| 3124 Split(equal, if_true, if_false, fall_through); | 3123 Split(equal, if_true, if_false, fall_through); |
| 3125 | 3124 |
| 3126 context()->Plug(if_true, if_false); | 3125 context()->Plug(if_true, if_false); |
| 3127 } | 3126 } |
| 3128 | 3127 |
| 3129 | 3128 |
| 3130 void FullCodeGenerator::EmitObjectEquals(CallRuntime* expr) { | 3129 void FullCodeGenerator::EmitObjectEquals(CallRuntime* expr) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3189 } | 3188 } |
| 3190 | 3189 |
| 3191 | 3190 |
| 3192 void FullCodeGenerator::EmitClassOf(CallRuntime* expr) { | 3191 void FullCodeGenerator::EmitClassOf(CallRuntime* expr) { |
| 3193 ZoneList<Expression*>* args = expr->arguments(); | 3192 ZoneList<Expression*>* args = expr->arguments(); |
| 3194 DCHECK(args->length() == 1); | 3193 DCHECK(args->length() == 1); |
| 3195 Label done, null, function, non_function_constructor; | 3194 Label done, null, function, non_function_constructor; |
| 3196 | 3195 |
| 3197 VisitForAccumulatorValue(args->at(0)); | 3196 VisitForAccumulatorValue(args->at(0)); |
| 3198 | 3197 |
| 3199 // If the object is a smi, we return null. | 3198 // If the object is not a JSReceiver, we return null. |
| 3200 __ JumpIfSmi(eax, &null); | 3199 __ JumpIfSmi(eax, &null, Label::kNear); |
| 3200 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
| 3201 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, eax); |
| 3202 __ j(below, &null, Label::kNear); |
| 3201 | 3203 |
| 3202 // Check that the object is a JS object but take special care of JS | 3204 // Return 'Function' for JSFunction objects. |
| 3203 // functions to make sure they have 'Function' as their class. | 3205 __ CmpInstanceType(eax, JS_FUNCTION_TYPE); |
| 3204 // Assume that there are only two callable types, and one of them is at | 3206 __ j(equal, &function, Label::kNear); |
| 3205 // either end of the type range for JS object types. Saves extra comparisons. | |
| 3206 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | |
| 3207 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, eax); | |
| 3208 // Map is now in eax. | |
| 3209 __ j(below, &null); | |
| 3210 | |
| 3211 __ CmpInstanceType(eax, LAST_JS_RECEIVER_TYPE); | |
| 3212 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | |
| 3213 LAST_JS_RECEIVER_TYPE - 1); | |
| 3214 __ j(equal, &function); | |
| 3215 // Assume that there is no larger type. | |
| 3216 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); | |
| 3217 | 3207 |
| 3218 // Check if the constructor in the map is a JS function. | 3208 // Check if the constructor in the map is a JS function. |
| 3219 __ GetMapConstructor(eax, eax, ebx); | 3209 __ GetMapConstructor(eax, eax, ebx); |
| 3220 __ CmpInstanceType(ebx, JS_FUNCTION_TYPE); | 3210 __ CmpInstanceType(ebx, JS_FUNCTION_TYPE); |
| 3221 __ j(not_equal, &non_function_constructor); | 3211 __ j(not_equal, &non_function_constructor, Label::kNear); |
| 3222 | 3212 |
| 3223 // eax now contains the constructor function. Grab the | 3213 // eax now contains the constructor function. Grab the |
| 3224 // instance class name from there. | 3214 // instance class name from there. |
| 3225 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset)); | 3215 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset)); |
| 3226 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kInstanceClassNameOffset)); | 3216 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kInstanceClassNameOffset)); |
| 3227 __ jmp(&done); | 3217 __ jmp(&done, Label::kNear); |
| 3218 |
| 3219 // Non-JS objects have class null. |
| 3220 __ bind(&null); |
| 3221 __ mov(eax, isolate()->factory()->null_value()); |
| 3222 __ jmp(&done, Label::kNear); |
| 3228 | 3223 |
| 3229 // Functions have class 'Function'. | 3224 // Functions have class 'Function'. |
| 3230 __ bind(&function); | 3225 __ bind(&function); |
| 3231 __ mov(eax, isolate()->factory()->Function_string()); | 3226 __ mov(eax, isolate()->factory()->Function_string()); |
| 3232 __ jmp(&done); | 3227 __ jmp(&done, Label::kNear); |
| 3233 | 3228 |
| 3234 // Objects with a non-function constructor have class 'Object'. | 3229 // Objects with a non-function constructor have class 'Object'. |
| 3235 __ bind(&non_function_constructor); | 3230 __ bind(&non_function_constructor); |
| 3236 __ mov(eax, isolate()->factory()->Object_string()); | 3231 __ mov(eax, isolate()->factory()->Object_string()); |
| 3237 __ jmp(&done); | |
| 3238 | |
| 3239 // Non-JS objects have class null. | |
| 3240 __ bind(&null); | |
| 3241 __ mov(eax, isolate()->factory()->null_value()); | |
| 3242 | 3232 |
| 3243 // All done. | 3233 // All done. |
| 3244 __ bind(&done); | 3234 __ bind(&done); |
| 3245 | 3235 |
| 3246 context()->Plug(eax); | 3236 context()->Plug(eax); |
| 3247 } | 3237 } |
| 3248 | 3238 |
| 3249 | 3239 |
| 3250 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { | 3240 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { |
| 3251 ZoneList<Expression*>* args = expr->arguments(); | 3241 ZoneList<Expression*>* args = expr->arguments(); |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4763 Assembler::target_address_at(call_target_address, | 4753 Assembler::target_address_at(call_target_address, |
| 4764 unoptimized_code)); | 4754 unoptimized_code)); |
| 4765 return OSR_AFTER_STACK_CHECK; | 4755 return OSR_AFTER_STACK_CHECK; |
| 4766 } | 4756 } |
| 4767 | 4757 |
| 4768 | 4758 |
| 4769 } // namespace internal | 4759 } // namespace internal |
| 4770 } // namespace v8 | 4760 } // namespace v8 |
| 4771 | 4761 |
| 4772 #endif // V8_TARGET_ARCH_X87 | 4762 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |