Chromium Code Reviews| 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 3157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3168 __ str(scratch2, MemOperand(index1, 0)); | 3168 __ str(scratch2, MemOperand(index1, 0)); |
| 3169 | 3169 |
| 3170 Label new_space; | 3170 Label new_space; |
| 3171 __ InNewSpace(elements, scratch1, eq, &new_space); | 3171 __ InNewSpace(elements, scratch1, eq, &new_space); |
| 3172 // Possible optimization: do a check that both values are Smis | 3172 // Possible optimization: do a check that both values are Smis |
| 3173 // (or them and test against Smi mask.) | 3173 // (or them and test against Smi mask.) |
| 3174 | 3174 |
| 3175 __ mov(scratch1, elements); | 3175 __ mov(scratch1, elements); |
| 3176 __ RecordWriteHelper(elements, index1, scratch2); | 3176 __ RecordWriteHelper(elements, index1, scratch2); |
| 3177 __ RecordWriteHelper(scratch1, index2, scratch2); // scratch1 holds elements. | 3177 __ RecordWriteHelper(scratch1, index2, scratch2); // scratch1 holds elements. |
| 3178 __ bind(&done); | |
| 3179 | 3178 |
| 3180 __ bind(&new_space); | 3179 __ bind(&new_space); |
| 3181 // We are done. Drop elements from the stack, and return undefined. | 3180 // We are done. Drop elements from the stack, and return undefined. |
| 3182 __ Drop(3); | 3181 __ Drop(3); |
| 3183 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 3182 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 3184 __ jmp(&done); | 3183 __ jmp(&done); |
| 3185 | 3184 |
| 3186 __ bind(&slow_case); | 3185 __ bind(&slow_case); |
| 3187 __ CallRuntime(Runtime::kSwapElements, 3); | 3186 __ CallRuntime(Runtime::kSwapElements, 3); |
| 3188 | 3187 |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3971 UnaryOperation* left_unary = left->AsUnaryOperation(); | 3970 UnaryOperation* left_unary = left->AsUnaryOperation(); |
| 3972 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; | 3971 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; |
| 3973 Handle<String> check = Handle<String>::cast(right_literal_value); | 3972 Handle<String> check = Handle<String>::cast(right_literal_value); |
| 3974 | 3973 |
| 3975 { AccumulatorValueContext context(this); | 3974 { AccumulatorValueContext context(this); |
| 3976 VisitForTypeofValue(left_unary->expression()); | 3975 VisitForTypeofValue(left_unary->expression()); |
| 3977 } | 3976 } |
| 3978 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 3977 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 3979 | 3978 |
| 3980 if (check->Equals(Heap::number_symbol())) { | 3979 if (check->Equals(Heap::number_symbol())) { |
| 3981 __ tst(r0, Operand(kSmiTagMask)); | 3980 __ JumpIfSmi(r0, if_true); |
| 3982 __ b(eq, if_true); | |
| 3983 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 3981 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 3984 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 3982 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
| 3985 __ cmp(r0, ip); | 3983 __ cmp(r0, ip); |
| 3986 Split(eq, if_true, if_false, fall_through); | 3984 Split(eq, if_true, if_false, fall_through); |
| 3987 } else if (check->Equals(Heap::string_symbol())) { | 3985 } else if (check->Equals(Heap::string_symbol())) { |
| 3988 __ tst(r0, Operand(kSmiTagMask)); | 3986 __ JumpIfSmi(r0, if_false); |
| 3989 __ b(eq, if_false); | |
| 3990 // Check for undetectable objects => false. | 3987 // Check for undetectable objects => false. |
| 3991 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 3988 __ CompareObjectType(r0, r0, r1, FIRST_NONSTRING_TYPE); |
| 3989 __ b(ge, if_false); | |
| 3992 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); | 3990 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); |
| 3993 __ and_(r1, r1, Operand(1 << Map::kIsUndetectable)); | 3991 __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 3994 __ cmp(r1, Operand(1 << Map::kIsUndetectable)); | 3992 Split(eq, if_true, if_false, fall_through); |
| 3995 __ b(eq, if_false); | |
| 3996 __ ldrb(r1, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | |
| 3997 __ cmp(r1, Operand(FIRST_NONSTRING_TYPE)); | |
| 3998 Split(lt, if_true, if_false, fall_through); | |
| 3999 } else if (check->Equals(Heap::boolean_symbol())) { | 3993 } else if (check->Equals(Heap::boolean_symbol())) { |
| 4000 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 3994 __ CompareRoot(r0, Heap::kTrueValueRootIndex); |
| 4001 __ cmp(r0, ip); | |
| 4002 __ b(eq, if_true); | 3995 __ b(eq, if_true); |
| 4003 __ LoadRoot(ip, Heap::kFalseValueRootIndex); | 3996 __ CompareRoot(r0, Heap::kFalseValueRootIndex); |
| 4004 __ cmp(r0, ip); | |
| 4005 Split(eq, if_true, if_false, fall_through); | 3997 Split(eq, if_true, if_false, fall_through); |
| 4006 } else if (check->Equals(Heap::undefined_symbol())) { | 3998 } else if (check->Equals(Heap::undefined_symbol())) { |
| 4007 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 3999 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); |
| 4008 __ cmp(r0, ip); | |
| 4009 __ b(eq, if_true); | 4000 __ b(eq, if_true); |
| 4010 __ tst(r0, Operand(kSmiTagMask)); | 4001 __ JumpIfSmi(r0, if_false); |
| 4011 __ b(eq, if_false); | |
| 4012 // Check for undetectable objects => true. | 4002 // Check for undetectable objects => true. |
| 4013 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 4003 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 4014 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); | 4004 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); |
| 4015 __ and_(r1, r1, Operand(1 << Map::kIsUndetectable)); | 4005 __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 4016 __ cmp(r1, Operand(1 << Map::kIsUndetectable)); | 4006 Split(ne, if_true, if_false, fall_through); |
| 4007 | |
| 4008 } else if (check->Equals(Heap::function_symbol())) { | |
| 4009 __ JumpIfSmi(r0, if_false); | |
| 4010 __ CompareObjectType(r0, r1, r0, FIRST_FUNCTION_CLASS_TYPE); | |
| 4011 Split(ge, if_true, if_false, fall_through); | |
| 4012 | |
| 4013 } else if (check->Equals(Heap::object_symbol())) { | |
| 4014 __ JumpIfSmi(r0, if_false); | |
| 4015 __ CompareRoot(r0, Heap::kNullValueRootIndex); | |
| 4016 __ b(eq, if_true); | |
| 4017 // Check for JS objects => true. | |
| 4018 __ CompareObjectType(r0, r0, r1, FIRST_JS_OBJECT_TYPE); | |
| 4019 __ b(lo, if_false); | |
| 4020 __ CompareInstanceType(r0, r1, FIRST_FUNCTION_CLASS_TYPE); | |
|
fschneider
2011/03/03 12:05:02
Could you reuse the value of the instance type fro
William Hesse
2011/03/03 12:16:13
It is being reused, and it is in r0. R1 is just a
| |
| 4021 __ b(hs, if_false); | |
| 4022 // Check for undetectable objects => false. | |
| 4023 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); | |
| 4024 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | |
| 4017 Split(eq, if_true, if_false, fall_through); | 4025 Split(eq, if_true, if_false, fall_through); |
| 4018 } else if (check->Equals(Heap::function_symbol())) { | |
| 4019 __ tst(r0, Operand(kSmiTagMask)); | |
| 4020 __ b(eq, if_false); | |
| 4021 __ CompareObjectType(r0, r1, r0, JS_FUNCTION_TYPE); | |
| 4022 __ b(eq, if_true); | |
| 4023 // Regular expressions => 'function' (they are callable). | |
| 4024 __ CompareInstanceType(r1, r0, JS_REGEXP_TYPE); | |
| 4025 Split(eq, if_true, if_false, fall_through); | |
| 4026 } else if (check->Equals(Heap::object_symbol())) { | |
| 4027 __ tst(r0, Operand(kSmiTagMask)); | |
| 4028 __ b(eq, if_false); | |
| 4029 __ LoadRoot(ip, Heap::kNullValueRootIndex); | |
| 4030 __ cmp(r0, ip); | |
| 4031 __ b(eq, if_true); | |
| 4032 // Regular expressions => 'function', not 'object'. | |
| 4033 __ CompareObjectType(r0, r1, r0, JS_REGEXP_TYPE); | |
| 4034 __ b(eq, if_false); | |
| 4035 // Check for undetectable objects => false. | |
| 4036 __ ldrb(r0, FieldMemOperand(r1, Map::kBitFieldOffset)); | |
| 4037 __ and_(r0, r0, Operand(1 << Map::kIsUndetectable)); | |
| 4038 __ cmp(r0, Operand(1 << Map::kIsUndetectable)); | |
| 4039 __ b(eq, if_false); | |
| 4040 // Check for JS objects => true. | |
| 4041 __ ldrb(r0, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | |
| 4042 __ cmp(r0, Operand(FIRST_JS_OBJECT_TYPE)); | |
| 4043 __ b(lt, if_false); | |
| 4044 __ cmp(r0, Operand(LAST_JS_OBJECT_TYPE)); | |
| 4045 Split(le, if_true, if_false, fall_through); | |
| 4046 } else { | 4026 } else { |
| 4047 if (if_false != fall_through) __ jmp(if_false); | 4027 if (if_false != fall_through) __ jmp(if_false); |
| 4048 } | 4028 } |
| 4049 | 4029 |
| 4050 return true; | 4030 return true; |
| 4051 } | 4031 } |
| 4052 | 4032 |
| 4053 | 4033 |
| 4054 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 4034 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| 4055 Comment cmnt(masm_, "[ CompareOperation"); | 4035 Comment cmnt(masm_, "[ CompareOperation"); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4297 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. | 4277 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. |
| 4298 __ add(pc, r1, Operand(masm_->CodeObject())); | 4278 __ add(pc, r1, Operand(masm_->CodeObject())); |
| 4299 } | 4279 } |
| 4300 | 4280 |
| 4301 | 4281 |
| 4302 #undef __ | 4282 #undef __ |
| 4303 | 4283 |
| 4304 } } // namespace v8::internal | 4284 } } // namespace v8::internal |
| 4305 | 4285 |
| 4306 #endif // V8_TARGET_ARCH_ARM | 4286 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |