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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 3037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3048 | 3048 |
3049 | 3049 |
3050 void MacroAssembler::JumpIfDictionaryInPrototypeChain( | 3050 void MacroAssembler::JumpIfDictionaryInPrototypeChain( |
3051 Register object, | 3051 Register object, |
3052 Register scratch0, | 3052 Register scratch0, |
3053 Register scratch1, | 3053 Register scratch1, |
3054 Label* found) { | 3054 Label* found) { |
3055 DCHECK(!scratch1.is(scratch0)); | 3055 DCHECK(!scratch1.is(scratch0)); |
3056 Factory* factory = isolate()->factory(); | 3056 Factory* factory = isolate()->factory(); |
3057 Register current = scratch0; | 3057 Register current = scratch0; |
3058 Label loop_again; | 3058 Label loop_again, end; |
3059 | 3059 |
3060 // scratch contained elements pointer. | 3060 // scratch contained elements pointer. |
3061 mov(current, object); | 3061 mov(current, object); |
| 3062 mov(current, FieldOperand(current, HeapObject::kMapOffset)); |
| 3063 mov(current, FieldOperand(current, Map::kPrototypeOffset)); |
| 3064 cmp(current, Immediate(factory->null_value())); |
| 3065 j(equal, &end); |
3062 | 3066 |
3063 // Loop based on the map going up the prototype chain. | 3067 // Loop based on the map going up the prototype chain. |
3064 bind(&loop_again); | 3068 bind(&loop_again); |
3065 mov(current, FieldOperand(current, HeapObject::kMapOffset)); | 3069 mov(current, FieldOperand(current, HeapObject::kMapOffset)); |
| 3070 STATIC_ASSERT(JS_PROXY_TYPE < JS_OBJECT_TYPE); |
| 3071 STATIC_ASSERT(JS_VALUE_TYPE < JS_OBJECT_TYPE); |
| 3072 CmpInstanceType(current, JS_OBJECT_TYPE); |
| 3073 j(below, found); |
3066 mov(scratch1, FieldOperand(current, Map::kBitField2Offset)); | 3074 mov(scratch1, FieldOperand(current, Map::kBitField2Offset)); |
3067 DecodeField<Map::ElementsKindBits>(scratch1); | 3075 DecodeField<Map::ElementsKindBits>(scratch1); |
3068 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS)); | 3076 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS)); |
3069 j(equal, found); | 3077 j(equal, found); |
3070 mov(current, FieldOperand(current, Map::kPrototypeOffset)); | 3078 mov(current, FieldOperand(current, Map::kPrototypeOffset)); |
3071 cmp(current, Immediate(factory->null_value())); | 3079 cmp(current, Immediate(factory->null_value())); |
3072 j(not_equal, &loop_again); | 3080 j(not_equal, &loop_again); |
| 3081 |
| 3082 bind(&end); |
3073 } | 3083 } |
3074 | 3084 |
3075 | 3085 |
3076 void MacroAssembler::TruncatingDiv(Register dividend, int32_t divisor) { | 3086 void MacroAssembler::TruncatingDiv(Register dividend, int32_t divisor) { |
3077 DCHECK(!dividend.is(eax)); | 3087 DCHECK(!dividend.is(eax)); |
3078 DCHECK(!dividend.is(edx)); | 3088 DCHECK(!dividend.is(edx)); |
3079 base::MagicNumbersForDivision<uint32_t> mag = | 3089 base::MagicNumbersForDivision<uint32_t> mag = |
3080 base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); | 3090 base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); |
3081 mov(eax, Immediate(mag.multiplier)); | 3091 mov(eax, Immediate(mag.multiplier)); |
3082 imul(dividend); | 3092 imul(dividend); |
3083 bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; | 3093 bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; |
3084 if (divisor > 0 && neg) add(edx, dividend); | 3094 if (divisor > 0 && neg) add(edx, dividend); |
3085 if (divisor < 0 && !neg && mag.multiplier > 0) sub(edx, dividend); | 3095 if (divisor < 0 && !neg && mag.multiplier > 0) sub(edx, dividend); |
3086 if (mag.shift > 0) sar(edx, mag.shift); | 3096 if (mag.shift > 0) sar(edx, mag.shift); |
3087 mov(eax, dividend); | 3097 mov(eax, dividend); |
3088 shr(eax, 31); | 3098 shr(eax, 31); |
3089 add(edx, eax); | 3099 add(edx, eax); |
3090 } | 3100 } |
3091 | 3101 |
3092 | 3102 |
3093 } // namespace internal | 3103 } // namespace internal |
3094 } // namespace v8 | 3104 } // namespace v8 |
3095 | 3105 |
3096 #endif // V8_TARGET_ARCH_X87 | 3106 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |