| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 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 3185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3196 } | 3196 } |
| 3197 | 3197 |
| 3198 | 3198 |
| 3199 void FullCodeGenerator::EmitClassOf(CallRuntime* expr) { | 3199 void FullCodeGenerator::EmitClassOf(CallRuntime* expr) { |
| 3200 ZoneList<Expression*>* args = expr->arguments(); | 3200 ZoneList<Expression*>* args = expr->arguments(); |
| 3201 DCHECK(args->length() == 1); | 3201 DCHECK(args->length() == 1); |
| 3202 Label done, null, function, non_function_constructor; | 3202 Label done, null, function, non_function_constructor; |
| 3203 | 3203 |
| 3204 VisitForAccumulatorValue(args->at(0)); | 3204 VisitForAccumulatorValue(args->at(0)); |
| 3205 | 3205 |
| 3206 // If the object is a smi, we return null. | 3206 // If the object is not a JSReceiver, we return null. |
| 3207 __ JumpIfSmi(eax, &null); | 3207 __ JumpIfSmi(eax, &null, Label::kNear); |
| 3208 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
| 3209 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, eax); |
| 3210 __ j(below, &null, Label::kNear); |
| 3208 | 3211 |
| 3209 // Check that the object is a JS object but take special care of JS | 3212 // Return 'Function' for JSFunction objects. |
| 3210 // functions to make sure they have 'Function' as their class. | 3213 __ CmpInstanceType(eax, JS_FUNCTION_TYPE); |
| 3211 // Assume that there are only two callable types, and one of them is at | 3214 __ j(equal, &function, Label::kNear); |
| 3212 // either end of the type range for JS object types. Saves extra comparisons. | |
| 3213 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | |
| 3214 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, eax); | |
| 3215 // Map is now in eax. | |
| 3216 __ j(below, &null); | |
| 3217 | |
| 3218 __ CmpInstanceType(eax, LAST_JS_RECEIVER_TYPE); | |
| 3219 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | |
| 3220 LAST_JS_RECEIVER_TYPE - 1); | |
| 3221 __ j(equal, &function); | |
| 3222 // Assume that there is no larger type. | |
| 3223 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); | |
| 3224 | 3215 |
| 3225 // Check if the constructor in the map is a JS function. | 3216 // Check if the constructor in the map is a JS function. |
| 3226 __ GetMapConstructor(eax, eax, ebx); | 3217 __ GetMapConstructor(eax, eax, ebx); |
| 3227 __ CmpInstanceType(ebx, JS_FUNCTION_TYPE); | 3218 __ CmpInstanceType(ebx, JS_FUNCTION_TYPE); |
| 3228 __ j(not_equal, &non_function_constructor); | 3219 __ j(not_equal, &non_function_constructor, Label::kNear); |
| 3229 | 3220 |
| 3230 // eax now contains the constructor function. Grab the | 3221 // eax now contains the constructor function. Grab the |
| 3231 // instance class name from there. | 3222 // instance class name from there. |
| 3232 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset)); | 3223 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset)); |
| 3233 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kInstanceClassNameOffset)); | 3224 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kInstanceClassNameOffset)); |
| 3234 __ jmp(&done); | 3225 __ jmp(&done, Label::kNear); |
| 3226 |
| 3227 // Non-JS objects have class null. |
| 3228 __ bind(&null); |
| 3229 __ mov(eax, isolate()->factory()->null_value()); |
| 3230 __ jmp(&done, Label::kNear); |
| 3235 | 3231 |
| 3236 // Functions have class 'Function'. | 3232 // Functions have class 'Function'. |
| 3237 __ bind(&function); | 3233 __ bind(&function); |
| 3238 __ mov(eax, isolate()->factory()->Function_string()); | 3234 __ mov(eax, isolate()->factory()->Function_string()); |
| 3239 __ jmp(&done); | 3235 __ jmp(&done, Label::kNear); |
| 3240 | 3236 |
| 3241 // Objects with a non-function constructor have class 'Object'. | 3237 // Objects with a non-function constructor have class 'Object'. |
| 3242 __ bind(&non_function_constructor); | 3238 __ bind(&non_function_constructor); |
| 3243 __ mov(eax, isolate()->factory()->Object_string()); | 3239 __ mov(eax, isolate()->factory()->Object_string()); |
| 3244 __ jmp(&done); | |
| 3245 | |
| 3246 // Non-JS objects have class null. | |
| 3247 __ bind(&null); | |
| 3248 __ mov(eax, isolate()->factory()->null_value()); | |
| 3249 | 3240 |
| 3250 // All done. | 3241 // All done. |
| 3251 __ bind(&done); | 3242 __ bind(&done); |
| 3252 | 3243 |
| 3253 context()->Plug(eax); | 3244 context()->Plug(eax); |
| 3254 } | 3245 } |
| 3255 | 3246 |
| 3256 | 3247 |
| 3257 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { | 3248 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { |
| 3258 ZoneList<Expression*>* args = expr->arguments(); | 3249 ZoneList<Expression*>* args = expr->arguments(); |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4770 Assembler::target_address_at(call_target_address, | 4761 Assembler::target_address_at(call_target_address, |
| 4771 unoptimized_code)); | 4762 unoptimized_code)); |
| 4772 return OSR_AFTER_STACK_CHECK; | 4763 return OSR_AFTER_STACK_CHECK; |
| 4773 } | 4764 } |
| 4774 | 4765 |
| 4775 | 4766 |
| 4776 } // namespace internal | 4767 } // namespace internal |
| 4777 } // namespace v8 | 4768 } // namespace v8 |
| 4778 | 4769 |
| 4779 #endif // V8_TARGET_ARCH_IA32 | 4770 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |