| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 case Token::SHL: | 1151 case Token::SHL: |
| 1152 ASSERT(!reversed_); | 1152 ASSERT(!reversed_); |
| 1153 if (shift_value != 0) { | 1153 if (shift_value != 0) { |
| 1154 __ mov(int32, Operand(int32, LSL, shift_value)); | 1154 __ mov(int32, Operand(int32, LSL, shift_value)); |
| 1155 } | 1155 } |
| 1156 break; | 1156 break; |
| 1157 default: UNREACHABLE(); | 1157 default: UNREACHABLE(); |
| 1158 } | 1158 } |
| 1159 // Check that the *signed* result fits in a smi. Not necessary for AND, SAR | 1159 // Check that the *signed* result fits in a smi. Not necessary for AND, SAR |
| 1160 // if the shift if more than 0 or SHR if the shit is more than 1. | 1160 // if the shift if more than 0 or SHR if the shit is more than 1. |
| 1161 if (!( (op_ == Token::AND) || | 1161 if (!( (op_ == Token::AND && value_ >= 0) || |
| 1162 ((op_ == Token::SAR) && (shift_value > 0)) || | 1162 ((op_ == Token::SAR) && (shift_value > 0)) || |
| 1163 ((op_ == Token::SHR) && (shift_value > 1)))) { | 1163 ((op_ == Token::SHR) && (shift_value > 1)))) { |
| 1164 __ add(r3, int32, Operand(0x40000000), SetCC); | 1164 __ add(r3, int32, Operand(0x40000000), SetCC); |
| 1165 __ b(mi, &result_not_a_smi); | 1165 __ b(mi, &result_not_a_smi); |
| 1166 } | 1166 } |
| 1167 __ mov(tos_register_, Operand(int32, LSL, kSmiTagSize)); | 1167 __ mov(tos_register_, Operand(int32, LSL, kSmiTagSize)); |
| 1168 Exit(); | 1168 Exit(); |
| 1169 | 1169 |
| 1170 if (result_not_a_smi.is_linked()) { | 1170 if (result_not_a_smi.is_linked()) { |
| 1171 __ bind(&result_not_a_smi); | 1171 __ bind(&result_not_a_smi); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 new DeferredInlineSmiOperation(op, int_value, reversed, mode, tos); | 1412 new DeferredInlineSmiOperation(op, int_value, reversed, mode, tos); |
| 1413 __ tst(tos, Operand(kSmiTagMask)); | 1413 __ tst(tos, Operand(kSmiTagMask)); |
| 1414 deferred->JumpToNonSmiInput(ne); | 1414 deferred->JumpToNonSmiInput(ne); |
| 1415 switch (op) { | 1415 switch (op) { |
| 1416 case Token::BIT_OR: __ orr(tos, tos, Operand(value)); break; | 1416 case Token::BIT_OR: __ orr(tos, tos, Operand(value)); break; |
| 1417 case Token::BIT_XOR: __ eor(tos, tos, Operand(value)); break; | 1417 case Token::BIT_XOR: __ eor(tos, tos, Operand(value)); break; |
| 1418 case Token::BIT_AND: __ And(tos, tos, Operand(value)); break; | 1418 case Token::BIT_AND: __ And(tos, tos, Operand(value)); break; |
| 1419 default: UNREACHABLE(); | 1419 default: UNREACHABLE(); |
| 1420 } | 1420 } |
| 1421 deferred->BindExit(); | 1421 deferred->BindExit(); |
| 1422 TypeInfo result_type = | 1422 TypeInfo result_type = TypeInfo::Integer32(); |
| 1423 (op == Token::BIT_AND) ? TypeInfo::Smi() : TypeInfo::Integer32(); | 1423 if (op == Token::BIT_AND && int_value >= 0) { |
| 1424 result_type = TypeInfo::Smi(); |
| 1425 } |
| 1424 frame_->EmitPush(tos, result_type); | 1426 frame_->EmitPush(tos, result_type); |
| 1425 } | 1427 } |
| 1426 break; | 1428 break; |
| 1427 } | 1429 } |
| 1428 | 1430 |
| 1429 case Token::SHL: | 1431 case Token::SHL: |
| 1430 if (reversed) { | 1432 if (reversed) { |
| 1431 ASSERT(both_sides_are_smi); | 1433 ASSERT(both_sides_are_smi); |
| 1432 int max_shift = 0; | 1434 int max_shift = 0; |
| 1433 int max_result = int_value == 0 ? 1 : int_value; | 1435 int max_result = int_value == 0 ? 1 : int_value; |
| (...skipping 4147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5581 frame_->EmitPop(index2); | 5583 frame_->EmitPop(index2); |
| 5582 frame_->EmitPop(index1); | 5584 frame_->EmitPop(index1); |
| 5583 frame_->EmitPop(object); | 5585 frame_->EmitPop(object); |
| 5584 | 5586 |
| 5585 DeferredSwapElements* deferred = | 5587 DeferredSwapElements* deferred = |
| 5586 new DeferredSwapElements(object, index1, index2); | 5588 new DeferredSwapElements(object, index1, index2); |
| 5587 | 5589 |
| 5588 // Fetch the map and check if array is in fast case. | 5590 // Fetch the map and check if array is in fast case. |
| 5589 // Check that object doesn't require security checks and | 5591 // Check that object doesn't require security checks and |
| 5590 // has no indexed interceptor. | 5592 // has no indexed interceptor. |
| 5591 __ CompareObjectType(object, tmp1, tmp2, FIRST_JS_OBJECT_TYPE); | 5593 __ CompareObjectType(object, tmp1, tmp2, JS_ARRAY_TYPE); |
| 5592 deferred->Branch(lt); | 5594 deferred->Branch(ne); |
| 5593 __ ldrb(tmp2, FieldMemOperand(tmp1, Map::kBitFieldOffset)); | 5595 __ ldrb(tmp2, FieldMemOperand(tmp1, Map::kBitFieldOffset)); |
| 5594 __ tst(tmp2, Operand(KeyedLoadIC::kSlowCaseBitFieldMask)); | 5596 __ tst(tmp2, Operand(KeyedLoadIC::kSlowCaseBitFieldMask)); |
| 5595 deferred->Branch(ne); | 5597 deferred->Branch(ne); |
| 5596 | 5598 |
| 5597 // Check the object's elements are in fast case and writable. | 5599 // Check the object's elements are in fast case and writable. |
| 5598 __ ldr(tmp1, FieldMemOperand(object, JSObject::kElementsOffset)); | 5600 __ ldr(tmp1, FieldMemOperand(object, JSObject::kElementsOffset)); |
| 5599 __ ldr(tmp2, FieldMemOperand(tmp1, HeapObject::kMapOffset)); | 5601 __ ldr(tmp2, FieldMemOperand(tmp1, HeapObject::kMapOffset)); |
| 5600 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); | 5602 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); |
| 5601 __ cmp(tmp2, ip); | 5603 __ cmp(tmp2, ip); |
| 5602 deferred->Branch(ne); | 5604 deferred->Branch(ne); |
| (...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7141 Register scratch1 = VirtualFrame::scratch0(); | 7143 Register scratch1 = VirtualFrame::scratch0(); |
| 7142 Register scratch2 = VirtualFrame::scratch1(); | 7144 Register scratch2 = VirtualFrame::scratch1(); |
| 7143 Register scratch3 = r3; | 7145 Register scratch3 = r3; |
| 7144 | 7146 |
| 7145 // Counter will be decremented in the deferred code. Placed here to avoid | 7147 // Counter will be decremented in the deferred code. Placed here to avoid |
| 7146 // having it in the instruction stream below where patching will occur. | 7148 // having it in the instruction stream below where patching will occur. |
| 7147 __ IncrementCounter(COUNTERS->keyed_store_inline(), 1, | 7149 __ IncrementCounter(COUNTERS->keyed_store_inline(), 1, |
| 7148 scratch1, scratch2); | 7150 scratch1, scratch2); |
| 7149 | 7151 |
| 7150 | 7152 |
| 7151 | |
| 7152 // Load the value, key and receiver from the stack. | 7153 // Load the value, key and receiver from the stack. |
| 7153 bool value_is_harmless = frame_->KnownSmiAt(0); | 7154 bool value_is_harmless = frame_->KnownSmiAt(0); |
| 7154 if (wb_info == NEVER_NEWSPACE) value_is_harmless = true; | 7155 if (wb_info == NEVER_NEWSPACE) value_is_harmless = true; |
| 7155 bool key_is_smi = frame_->KnownSmiAt(1); | 7156 bool key_is_smi = frame_->KnownSmiAt(1); |
| 7156 Register value = frame_->PopToRegister(); | 7157 Register value = frame_->PopToRegister(); |
| 7157 Register key = frame_->PopToRegister(value); | 7158 Register key = frame_->PopToRegister(value); |
| 7158 VirtualFrame::SpilledScope spilled(frame_); | 7159 VirtualFrame::SpilledScope spilled(frame_); |
| 7159 Register receiver = r2; | 7160 Register receiver = r2; |
| 7160 frame_->EmitPop(receiver); | 7161 frame_->EmitPop(receiver); |
| 7161 | 7162 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 7189 } | 7190 } |
| 7190 | 7191 |
| 7191 // Check that the receiver is a heap object. | 7192 // Check that the receiver is a heap object. |
| 7192 __ tst(receiver, Operand(kSmiTagMask)); | 7193 __ tst(receiver, Operand(kSmiTagMask)); |
| 7193 deferred->Branch(eq); | 7194 deferred->Branch(eq); |
| 7194 | 7195 |
| 7195 // Check that the receiver is a JSArray. | 7196 // Check that the receiver is a JSArray. |
| 7196 __ CompareObjectType(receiver, scratch1, scratch1, JS_ARRAY_TYPE); | 7197 __ CompareObjectType(receiver, scratch1, scratch1, JS_ARRAY_TYPE); |
| 7197 deferred->Branch(ne); | 7198 deferred->Branch(ne); |
| 7198 | 7199 |
| 7199 // Check that the key is within bounds. Both the key and the length of | |
| 7200 // the JSArray are smis. Use unsigned comparison to handle negative keys. | |
| 7201 __ ldr(scratch1, FieldMemOperand(receiver, JSArray::kLengthOffset)); | |
| 7202 __ cmp(scratch1, key); | |
| 7203 deferred->Branch(ls); // Unsigned less equal. | |
| 7204 | |
| 7205 // Get the elements array from the receiver. | 7200 // Get the elements array from the receiver. |
| 7206 __ ldr(scratch1, FieldMemOperand(receiver, JSObject::kElementsOffset)); | 7201 __ ldr(scratch1, FieldMemOperand(receiver, JSObject::kElementsOffset)); |
| 7207 if (!value_is_harmless && wb_info != LIKELY_SMI) { | 7202 if (!value_is_harmless && wb_info != LIKELY_SMI) { |
| 7208 Label ok; | 7203 Label ok; |
| 7209 __ and_(scratch2, scratch1, Operand(ExternalReference::new_space_mask())); | 7204 __ and_(scratch2, scratch1, Operand(ExternalReference::new_space_mask())); |
| 7210 __ cmp(scratch2, Operand(ExternalReference::new_space_start())); | 7205 __ cmp(scratch2, Operand(ExternalReference::new_space_start())); |
| 7211 __ tst(value, Operand(kSmiTagMask), ne); | 7206 __ tst(value, Operand(kSmiTagMask), ne); |
| 7212 deferred->Branch(ne); | 7207 deferred->Branch(ne); |
| 7213 #ifdef DEBUG | 7208 #ifdef DEBUG |
| 7214 we_remembered_the_write_barrier = true; | 7209 we_remembered_the_write_barrier = true; |
| 7215 #endif | 7210 #endif |
| 7216 } | 7211 } |
| 7217 // Check that the elements array is not a dictionary. | 7212 // Check that the elements array is not a dictionary. |
| 7218 __ ldr(scratch2, FieldMemOperand(scratch1, JSObject::kMapOffset)); | 7213 __ ldr(scratch2, FieldMemOperand(scratch1, JSObject::kMapOffset)); |
| 7214 |
| 7219 // The following instructions are the part of the inlined store keyed | 7215 // The following instructions are the part of the inlined store keyed |
| 7220 // property code which can be patched. Therefore the exact number of | 7216 // property code which can be patched. Therefore the exact number of |
| 7221 // instructions generated need to be fixed, so the constant pool is blocked | 7217 // instructions generated need to be fixed, so the constant pool is blocked |
| 7222 // while generating this code. | 7218 // while generating this code. |
| 7223 { Assembler::BlockConstPoolScope block_const_pool(masm_); | 7219 { Assembler::BlockConstPoolScope block_const_pool(masm_); |
| 7224 #ifdef DEBUG | 7220 #ifdef DEBUG |
| 7225 Label check_inlined_codesize; | 7221 Label check_inlined_codesize; |
| 7226 masm_->bind(&check_inlined_codesize); | 7222 masm_->bind(&check_inlined_codesize); |
| 7227 #endif | 7223 #endif |
| 7228 | 7224 |
| 7229 // Read the fixed array map from the constant pool (not from the root | 7225 // Read the fixed array map from the constant pool (not from the root |
| 7230 // array) so that the value can be patched. When debugging, we patch this | 7226 // array) so that the value can be patched. When debugging, we patch this |
| 7231 // comparison to always fail so that we will hit the IC call in the | 7227 // comparison to always fail so that we will hit the IC call in the |
| 7232 // deferred code which will allow the debugger to break for fast case | 7228 // deferred code which will allow the debugger to break for fast case |
| 7233 // stores. | 7229 // stores. |
| 7234 __ mov(scratch3, Operand(FACTORY->fixed_array_map())); | 7230 __ mov(scratch3, Operand(FACTORY->fixed_array_map())); |
| 7235 __ cmp(scratch2, scratch3); | 7231 __ cmp(scratch2, scratch3); |
| 7236 deferred->Branch(ne); | 7232 deferred->Branch(ne); |
| 7237 | 7233 |
| 7234 // Check that the key is within bounds. Both the key and the length of |
| 7235 // the JSArray are smis (because the fixed array check above ensures the |
| 7236 // elements are in fast case). Use unsigned comparison to handle negative |
| 7237 // keys. |
| 7238 __ ldr(scratch3, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 7239 __ cmp(scratch3, key); |
| 7240 deferred->Branch(ls); // Unsigned less equal. |
| 7241 |
| 7238 // Store the value. | 7242 // Store the value. |
| 7239 __ add(scratch1, scratch1, | 7243 __ add(scratch1, scratch1, |
| 7240 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 7244 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 7241 __ str(value, | 7245 __ str(value, |
| 7242 MemOperand(scratch1, key, LSL, | 7246 MemOperand(scratch1, key, LSL, |
| 7243 kPointerSizeLog2 - (kSmiTagSize + kSmiShiftSize))); | 7247 kPointerSizeLog2 - (kSmiTagSize + kSmiShiftSize))); |
| 7244 | 7248 |
| 7245 // Make sure that the expected number of instructions are generated. | 7249 // Make sure that the expected number of instructions are generated. |
| 7246 ASSERT_EQ(kInlinedKeyedStoreInstructionsAfterPatch, | 7250 ASSERT_EQ(kInlinedKeyedStoreInstructionsAfterPatch, |
| 7247 masm_->InstructionsGeneratedSince(&check_inlined_codesize)); | 7251 masm_->InstructionsGeneratedSince(&check_inlined_codesize)); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7411 specialized_on_rhs_ ? "_ConstantRhs" : "", | 7415 specialized_on_rhs_ ? "_ConstantRhs" : "", |
| 7412 BinaryOpIC::GetName(runtime_operands_type_)); | 7416 BinaryOpIC::GetName(runtime_operands_type_)); |
| 7413 return name_; | 7417 return name_; |
| 7414 } | 7418 } |
| 7415 | 7419 |
| 7416 #undef __ | 7420 #undef __ |
| 7417 | 7421 |
| 7418 } } // namespace v8::internal | 7422 } } // namespace v8::internal |
| 7419 | 7423 |
| 7420 #endif // V8_TARGET_ARCH_ARM | 7424 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |