Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 3158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3169 | 3169 |
| 3170 // Discard old TOS value and push r0 on the stack (same as Pop(), push(r0)). | 3170 // Discard old TOS value and push r0 on the stack (same as Pop(), push(r0)). |
| 3171 __ str(r0, frame_->Top()); | 3171 __ str(r0, frame_->Top()); |
| 3172 ASSERT(frame_->height() == original_height + 1); | 3172 ASSERT(frame_->height() == original_height + 1); |
| 3173 } | 3173 } |
| 3174 | 3174 |
| 3175 | 3175 |
| 3176 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) { | 3176 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) { |
| 3177 VirtualFrame::SpilledScope spilled_scope; | 3177 VirtualFrame::SpilledScope spilled_scope; |
| 3178 ASSERT(args->length() == 1); | 3178 ASSERT(args->length() == 1); |
| 3179 LoadAndSpill(args->at(0)); // Load the object. | 3179 JumpTarget leave, null, function, non_function_constructor; |
| 3180 frame_->CallRuntime(Runtime::kClassOf, 1); | 3180 |
| 3181 // Load the object into r0. | |
| 3182 LoadAndSpill(args->at(0)); | |
| 3183 frame_->EmitPop(r0); | |
| 3184 | |
| 3185 // If the object is a smi, we return null. | |
| 3186 __ tst(r0, Operand(kSmiTagMask)); | |
| 3187 null.Branch(eq); | |
|
Erik Corry
2009/07/02 13:48:31
Ideally I'd like to do this as a conditional move
| |
| 3188 | |
| 3189 // Check that the object is a JS object but take special care of JS | |
| 3190 // functions to make sure they have 'Function' as their class. | |
| 3191 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | |
| 3192 __ ldrb(r1, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | |
| 3193 __ cmp(r1, Operand(FIRST_JS_OBJECT_TYPE)); | |
|
Erik Corry
2009/07/02 13:48:31
You can do these 3 in one with __ CompareObjectTyp
Mads Ager (chromium)
2009/07/02 14:14:08
Ah, yes, there is one more register parameter to C
| |
| 3194 null.Branch(lt); | |
| 3195 | |
| 3196 // As long as JS_FUNCTION_TYPE is the last instance type and it is | |
| 3197 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for | |
| 3198 // LAST_JS_OBJECT_TYPE. | |
| 3199 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | |
| 3200 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); | |
| 3201 __ cmp(r1, Operand(JS_FUNCTION_TYPE)); | |
| 3202 function.Branch(eq); | |
| 3203 | |
| 3204 // Check if the constructor in the map is a function. | |
| 3205 __ ldr(r0, FieldMemOperand(r0, Map::kConstructorOffset)); | |
| 3206 __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); | |
|
Erik Corry
2009/07/02 13:48:31
r0 = Object.
r1 = Map.
r1 = type (overwrites map)
Mads Ager (chromium)
2009/07/02 14:14:08
Yes, that is fine. All I need is for the construc
| |
| 3207 non_function_constructor.Branch(ne); | |
| 3208 | |
| 3209 // The map register now contains the constructor function. Grab the | |
|
Erik Corry
2009/07/02 13:48:31
Map register is r0? I think r0 is the constructor
Mads Ager (chromium)
2009/07/02 14:14:08
Yeah, strange comment. Changed it to 'The r0 regi
| |
| 3210 // instance class name from there. | |
| 3211 __ ldr(r0, FieldMemOperand(r0, JSFunction::kSharedFunctionInfoOffset)); | |
| 3212 __ ldr(r0, FieldMemOperand(r0, SharedFunctionInfo::kInstanceClassNameOffset)); | |
| 3181 frame_->EmitPush(r0); | 3213 frame_->EmitPush(r0); |
| 3214 leave.Jump(); | |
| 3215 | |
| 3216 // Functions have class 'Function'. | |
| 3217 function.Bind(); | |
| 3218 __ mov(r0, Operand(Factory::function_class_symbol())); | |
| 3219 frame_->EmitPush(r0); | |
| 3220 leave.Jump(); | |
| 3221 | |
| 3222 // Objects with a non-function constructor have class 'Object'. | |
| 3223 non_function_constructor.Bind(); | |
| 3224 __ mov(r0, Operand(Factory::Object_symbol())); | |
| 3225 frame_->EmitPush(r0); | |
| 3226 leave.Jump(); | |
| 3227 | |
| 3228 // Non-JS objects have class null. | |
| 3229 null.Bind(); | |
| 3230 __ mov(r0, Operand(Factory::null_value())); | |
| 3231 frame_->EmitPush(r0); | |
| 3232 | |
| 3233 // All done. | |
| 3234 leave.Bind(); | |
| 3182 } | 3235 } |
| 3183 | 3236 |
| 3184 | 3237 |
| 3185 void CodeGenerator::GenerateValueOf(ZoneList<Expression*>* args) { | 3238 void CodeGenerator::GenerateValueOf(ZoneList<Expression*>* args) { |
| 3186 VirtualFrame::SpilledScope spilled_scope; | 3239 VirtualFrame::SpilledScope spilled_scope; |
| 3187 ASSERT(args->length() == 1); | 3240 ASSERT(args->length() == 1); |
| 3188 JumpTarget leave; | 3241 JumpTarget leave; |
| 3189 LoadAndSpill(args->at(0)); | 3242 LoadAndSpill(args->at(0)); |
| 3190 frame_->EmitPop(r0); // r0 contains object. | 3243 frame_->EmitPop(r0); // r0 contains object. |
| 3191 // if (object->IsSmi()) return the object. | 3244 // if (object->IsSmi()) return the object. |
| (...skipping 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6049 int CompareStub::MinorKey() { | 6102 int CompareStub::MinorKey() { |
| 6050 // Encode the two parameters in a unique 16 bit value. | 6103 // Encode the two parameters in a unique 16 bit value. |
| 6051 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); | 6104 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); |
| 6052 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); | 6105 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); |
| 6053 } | 6106 } |
| 6054 | 6107 |
| 6055 | 6108 |
| 6056 #undef __ | 6109 #undef __ |
| 6057 | 6110 |
| 6058 } } // namespace v8::internal | 6111 } } // namespace v8::internal |
| OLD | NEW |