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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 885 __ cmp(r0, ip); | 885 __ cmp(r0, ip); |
| 886 __ b(eq, &exit); | 886 __ b(eq, &exit); |
| 887 Register null_value = r5; | 887 Register null_value = r5; |
| 888 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 888 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
| 889 __ cmp(r0, null_value); | 889 __ cmp(r0, null_value); |
| 890 __ b(eq, &exit); | 890 __ b(eq, &exit); |
| 891 | 891 |
| 892 // Convert the object to a JS object. | 892 // Convert the object to a JS object. |
| 893 Label convert, done_convert; | 893 Label convert, done_convert; |
| 894 __ JumpIfSmi(r0, &convert); | 894 __ JumpIfSmi(r0, &convert); |
| 895 __ CompareObjectType(r0, r1, r1, FIRST_JS_OBJECT_TYPE); | 895 __ CompareObjectType(r0, r1, r1, FIRST_SPEC_OBJECT_TYPE); |
| 896 __ b(hs, &done_convert); | 896 __ b(hs, &done_convert); |
|
Kevin Millikin (Chromium)
2011/05/30 16:32:29
See, here is 'hs'.
rossberg
2011/05/31 14:50:24
Changed to ge.
| |
| 897 __ bind(&convert); | 897 __ bind(&convert); |
| 898 __ push(r0); | 898 __ push(r0); |
| 899 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 899 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
| 900 __ bind(&done_convert); | 900 __ bind(&done_convert); |
| 901 __ push(r0); | 901 __ push(r0); |
| 902 | 902 |
| 903 // Check cache validity in generated code. This is a fast case for | 903 // Check cache validity in generated code. This is a fast case for |
| 904 // the JSObject::IsSimpleEnum cache validity checks. If we cannot | 904 // the JSObject::IsSimpleEnum cache validity checks. If we cannot |
| 905 // guarantee cache validity, call the runtime system to check cache | 905 // guarantee cache validity, call the runtime system to check cache |
| 906 // validity or get the property names in a fixed array. | 906 // validity or get the property names in a fixed array. |
| (...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2430 &if_true, &if_false, &fall_through); | 2430 &if_true, &if_false, &fall_through); |
| 2431 | 2431 |
| 2432 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 2432 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 2433 __ tst(r0, Operand(kSmiTagMask | 0x80000000)); | 2433 __ tst(r0, Operand(kSmiTagMask | 0x80000000)); |
| 2434 Split(eq, if_true, if_false, fall_through); | 2434 Split(eq, if_true, if_false, fall_through); |
| 2435 | 2435 |
| 2436 context()->Plug(if_true, if_false); | 2436 context()->Plug(if_true, if_false); |
| 2437 } | 2437 } |
| 2438 | 2438 |
| 2439 | 2439 |
| 2440 void FullCodeGenerator::EmitIsObject(ZoneList<Expression*>* args) { | 2440 void FullCodeGenerator::EmitIsObject(ZoneList<Expression*>* args) { |
|
Kevin Millikin (Chromium)
2011/05/26 13:30:10
We should probably name the corresponding runtime
rossberg
2011/05/31 14:50:24
Hm, SpecObject includes functions, so that would p
| |
| 2441 ASSERT(args->length() == 1); | 2441 ASSERT(args->length() == 1); |
| 2442 | 2442 |
| 2443 VisitForAccumulatorValue(args->at(0)); | 2443 VisitForAccumulatorValue(args->at(0)); |
| 2444 | 2444 |
| 2445 Label materialize_true, materialize_false; | 2445 Label materialize_true, materialize_false; |
| 2446 Label* if_true = NULL; | 2446 Label* if_true = NULL; |
| 2447 Label* if_false = NULL; | 2447 Label* if_false = NULL; |
| 2448 Label* fall_through = NULL; | 2448 Label* fall_through = NULL; |
| 2449 context()->PrepareTest(&materialize_true, &materialize_false, | 2449 context()->PrepareTest(&materialize_true, &materialize_false, |
| 2450 &if_true, &if_false, &fall_through); | 2450 &if_true, &if_false, &fall_through); |
| 2451 | 2451 |
| 2452 __ JumpIfSmi(r0, if_false); | 2452 __ JumpIfSmi(r0, if_false); |
| 2453 __ LoadRoot(ip, Heap::kNullValueRootIndex); | 2453 __ LoadRoot(ip, Heap::kNullValueRootIndex); |
| 2454 __ cmp(r0, ip); | 2454 __ cmp(r0, ip); |
| 2455 __ b(eq, if_true); | 2455 __ b(eq, if_true); |
| 2456 __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); | 2456 __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 2457 // Undetectable objects behave like undefined when tested with typeof. | 2457 // Undetectable objects behave like undefined when tested with typeof. |
| 2458 __ ldrb(r1, FieldMemOperand(r2, Map::kBitFieldOffset)); | 2458 __ ldrb(r1, FieldMemOperand(r2, Map::kBitFieldOffset)); |
| 2459 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | 2459 __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 2460 __ b(ne, if_false); | 2460 __ b(ne, if_false); |
| 2461 __ ldrb(r1, FieldMemOperand(r2, Map::kInstanceTypeOffset)); | 2461 __ ldrb(r1, FieldMemOperand(r2, Map::kInstanceTypeOffset)); |
| 2462 __ cmp(r1, Operand(FIRST_JS_OBJECT_TYPE)); | 2462 __ cmp(r1, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 2463 __ b(lt, if_false); | 2463 __ b(lt, if_false); |
| 2464 __ cmp(r1, Operand(LAST_JS_OBJECT_TYPE)); | 2464 __ cmp(r1, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 2465 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 2465 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 2466 Split(le, if_true, if_false, fall_through); | 2466 Split(le, if_true, if_false, fall_through); |
| 2467 | 2467 |
| 2468 context()->Plug(if_true, if_false); | 2468 context()->Plug(if_true, if_false); |
| 2469 } | 2469 } |
| 2470 | 2470 |
| 2471 | 2471 |
| 2472 void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) { | 2472 void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) { |
| 2473 ASSERT(args->length() == 1); | 2473 ASSERT(args->length() == 1); |
| 2474 | 2474 |
| 2475 VisitForAccumulatorValue(args->at(0)); | 2475 VisitForAccumulatorValue(args->at(0)); |
| 2476 | 2476 |
| 2477 Label materialize_true, materialize_false; | 2477 Label materialize_true, materialize_false; |
| 2478 Label* if_true = NULL; | 2478 Label* if_true = NULL; |
| 2479 Label* if_false = NULL; | 2479 Label* if_false = NULL; |
| 2480 Label* fall_through = NULL; | 2480 Label* fall_through = NULL; |
| 2481 context()->PrepareTest(&materialize_true, &materialize_false, | 2481 context()->PrepareTest(&materialize_true, &materialize_false, |
| 2482 &if_true, &if_false, &fall_through); | 2482 &if_true, &if_false, &fall_through); |
| 2483 | 2483 |
| 2484 __ JumpIfSmi(r0, if_false); | 2484 __ JumpIfSmi(r0, if_false); |
| 2485 __ CompareObjectType(r0, r1, r1, FIRST_JS_OBJECT_TYPE); | 2485 __ CompareObjectType(r0, r1, r1, FIRST_SPEC_OBJECT_TYPE); |
| 2486 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 2486 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 2487 Split(ge, if_true, if_false, fall_through); | 2487 Split(ge, if_true, if_false, fall_through); |
| 2488 | 2488 |
| 2489 context()->Plug(if_true, if_false); | 2489 context()->Plug(if_true, if_false); |
| 2490 } | 2490 } |
| 2491 | 2491 |
| 2492 | 2492 |
| 2493 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) { | 2493 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) { |
| 2494 ASSERT(args->length() == 1); | 2494 ASSERT(args->length() == 1); |
| 2495 | 2495 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2758 ASSERT(args->length() == 1); | 2758 ASSERT(args->length() == 1); |
| 2759 Label done, null, function, non_function_constructor; | 2759 Label done, null, function, non_function_constructor; |
| 2760 | 2760 |
| 2761 VisitForAccumulatorValue(args->at(0)); | 2761 VisitForAccumulatorValue(args->at(0)); |
| 2762 | 2762 |
| 2763 // If the object is a smi, we return null. | 2763 // If the object is a smi, we return null. |
| 2764 __ JumpIfSmi(r0, &null); | 2764 __ JumpIfSmi(r0, &null); |
| 2765 | 2765 |
| 2766 // Check that the object is a JS object but take special care of JS | 2766 // Check that the object is a JS object but take special care of JS |
| 2767 // functions to make sure they have 'Function' as their class. | 2767 // functions to make sure they have 'Function' as their class. |
| 2768 __ CompareObjectType(r0, r0, r1, FIRST_JS_OBJECT_TYPE); // Map is now in r0. | 2768 __ CompareObjectType(r0, r0, r1, FIRST_SPEC_OBJECT_TYPE); |
| 2769 // Map is now in r0. | |
| 2769 __ b(lt, &null); | 2770 __ b(lt, &null); |
| 2770 | 2771 |
| 2771 // As long as JS_FUNCTION_TYPE is the last instance type and it is | 2772 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type, and |
| 2772 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for | 2773 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after |
| 2773 // LAST_JS_OBJECT_TYPE. | 2774 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. |
| 2774 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 2775 ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); |
| 2775 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); | 2776 ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == |
| 2776 __ cmp(r1, Operand(JS_FUNCTION_TYPE)); | 2777 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); |
| 2777 __ b(eq, &function); | 2778 __ cmp(r1, Operand(FIRST_CALLABLE_SPEC_OBJECT_TYPE)); |
| 2779 __ b(hs, &function); | |
|
Kevin Millikin (Chromium)
2011/05/30 16:32:29
This should possibly be "hs" --> "ge".
rossberg
2011/05/31 14:50:24
Done.
| |
| 2778 | 2780 |
| 2779 // Check if the constructor in the map is a function. | 2781 // Check if the constructor in the map is a function. |
| 2780 __ ldr(r0, FieldMemOperand(r0, Map::kConstructorOffset)); | 2782 __ ldr(r0, FieldMemOperand(r0, Map::kConstructorOffset)); |
| 2781 __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); | 2783 __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); |
| 2782 __ b(ne, &non_function_constructor); | 2784 __ b(ne, &non_function_constructor); |
| 2783 | 2785 |
| 2784 // r0 now contains the constructor function. Grab the | 2786 // r0 now contains the constructor function. Grab the |
| 2785 // instance class name from there. | 2787 // instance class name from there. |
| 2786 __ ldr(r0, FieldMemOperand(r0, JSFunction::kSharedFunctionInfoOffset)); | 2788 __ ldr(r0, FieldMemOperand(r0, JSFunction::kSharedFunctionInfoOffset)); |
| 2787 __ ldr(r0, FieldMemOperand(r0, SharedFunctionInfo::kInstanceClassNameOffset)); | 2789 __ ldr(r0, FieldMemOperand(r0, SharedFunctionInfo::kInstanceClassNameOffset)); |
| (...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4062 __ b(eq, if_true); | 4064 __ b(eq, if_true); |
| 4063 __ JumpIfSmi(r0, if_false); | 4065 __ JumpIfSmi(r0, if_false); |
| 4064 // Check for undetectable objects => true. | 4066 // Check for undetectable objects => true. |
| 4065 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 4067 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 4066 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); | 4068 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); |
| 4067 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | 4069 __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 4068 Split(ne, if_true, if_false, fall_through); | 4070 Split(ne, if_true, if_false, fall_through); |
| 4069 | 4071 |
| 4070 } else if (check->Equals(isolate()->heap()->function_symbol())) { | 4072 } else if (check->Equals(isolate()->heap()->function_symbol())) { |
| 4071 __ JumpIfSmi(r0, if_false); | 4073 __ JumpIfSmi(r0, if_false); |
| 4072 __ CompareObjectType(r0, r1, r0, FIRST_FUNCTION_CLASS_TYPE); | 4074 __ CompareObjectType(r0, r1, r0, FIRST_CALLABLE_SPEC_OBJECT_TYPE); |
| 4073 Split(ge, if_true, if_false, fall_through); | 4075 Split(ge, if_true, if_false, fall_through); |
| 4074 | 4076 |
| 4075 } else if (check->Equals(isolate()->heap()->object_symbol())) { | 4077 } else if (check->Equals(isolate()->heap()->object_symbol())) { |
| 4076 __ JumpIfSmi(r0, if_false); | 4078 __ JumpIfSmi(r0, if_false); |
| 4077 __ CompareRoot(r0, Heap::kNullValueRootIndex); | 4079 __ CompareRoot(r0, Heap::kNullValueRootIndex); |
| 4078 __ b(eq, if_true); | 4080 __ b(eq, if_true); |
| 4079 // Check for JS objects => true. | 4081 // Check for JS objects => true. |
| 4080 __ CompareObjectType(r0, r0, r1, FIRST_JS_OBJECT_TYPE); | 4082 __ CompareObjectType(r0, r0, r1, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE); |
| 4081 __ b(lo, if_false); | 4083 __ b(lo, if_false); |
|
Kevin Millikin (Chromium)
2011/05/30 16:32:29
Likewise, "lo" --> "lt" here and "hi" --> "gt" jus
rossberg
2011/05/31 14:50:24
Done.
| |
| 4082 __ CompareInstanceType(r0, r1, FIRST_FUNCTION_CLASS_TYPE); | 4084 __ CompareInstanceType(r0, r1, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
| 4083 __ b(hs, if_false); | 4085 __ b(hi, if_false); |
| 4084 // Check for undetectable objects => false. | 4086 // Check for undetectable objects => false. |
| 4085 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); | 4087 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); |
| 4086 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | 4088 __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 4087 Split(eq, if_true, if_false, fall_through); | 4089 Split(eq, if_true, if_false, fall_through); |
| 4088 } else { | 4090 } else { |
| 4089 if (if_false != fall_through) __ jmp(if_false); | 4091 if (if_false != fall_through) __ jmp(if_false); |
| 4090 } | 4092 } |
| 4091 | 4093 |
| 4092 return true; | 4094 return true; |
| 4093 } | 4095 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4355 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. | 4357 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. |
| 4356 __ add(pc, r1, Operand(masm_->CodeObject())); | 4358 __ add(pc, r1, Operand(masm_->CodeObject())); |
| 4357 } | 4359 } |
| 4358 | 4360 |
| 4359 | 4361 |
| 4360 #undef __ | 4362 #undef __ |
| 4361 | 4363 |
| 4362 } } // namespace v8::internal | 4364 } } // namespace v8::internal |
| 4363 | 4365 |
| 4364 #endif // V8_TARGET_ARCH_ARM | 4366 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |