| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/code-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
| 6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
| 7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" |
| 8 #include "src/frames.h" | 8 #include "src/frames.h" |
| 9 #include "src/ic/handler-configuration.h" | 9 #include "src/ic/handler-configuration.h" |
| 10 #include "src/ic/stub-cache.h" | 10 #include "src/ic/stub-cache.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 Node* CodeStubAssembler::BooleanMapConstant() { | 41 Node* CodeStubAssembler::BooleanMapConstant() { |
| 42 return HeapConstant(isolate()->factory()->boolean_map()); | 42 return HeapConstant(isolate()->factory()->boolean_map()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 Node* CodeStubAssembler::EmptyStringConstant() { | 45 Node* CodeStubAssembler::EmptyStringConstant() { |
| 46 return LoadRoot(Heap::kempty_stringRootIndex); | 46 return LoadRoot(Heap::kempty_stringRootIndex); |
| 47 } | 47 } |
| 48 | 48 |
| 49 Node* CodeStubAssembler::HeapNumberMapConstant() { | 49 Node* CodeStubAssembler::HeapNumberMapConstant() { |
| 50 return HeapConstant(isolate()->factory()->heap_number_map()); | 50 return LoadRoot(Heap::kHeapNumberMapRootIndex); |
| 51 } | 51 } |
| 52 | 52 |
| 53 Node* CodeStubAssembler::NoContextConstant() { | 53 Node* CodeStubAssembler::NoContextConstant() { |
| 54 return SmiConstant(Smi::FromInt(0)); | 54 return SmiConstant(Smi::FromInt(0)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 Node* CodeStubAssembler::MinusZeroConstant() { | 57 Node* CodeStubAssembler::MinusZeroConstant() { |
| 58 return LoadRoot(Heap::kMinusZeroValueRootIndex); | 58 return LoadRoot(Heap::kMinusZeroValueRootIndex); |
| 59 } | 59 } |
| 60 | 60 |
| (...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 | 1225 |
| 1226 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( | 1226 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( |
| 1227 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { | 1227 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { |
| 1228 Node* offset = | 1228 Node* offset = |
| 1229 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, | 1229 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, |
| 1230 FixedArray::kHeaderSize - kHeapObjectTag); | 1230 FixedArray::kHeaderSize - kHeapObjectTag); |
| 1231 MachineRepresentation rep = MachineRepresentation::kFloat64; | 1231 MachineRepresentation rep = MachineRepresentation::kFloat64; |
| 1232 return StoreNoWriteBarrier(rep, object, offset, value); | 1232 return StoreNoWriteBarrier(rep, object, offset, value); |
| 1233 } | 1233 } |
| 1234 | 1234 |
| 1235 Node* CodeStubAssembler::AllocateHeapNumber() { | 1235 Node* CodeStubAssembler::AllocateHeapNumber(MutableMode mode) { |
| 1236 Node* result = Allocate(HeapNumber::kSize, kNone); | 1236 Node* result = Allocate(HeapNumber::kSize, kNone); |
| 1237 StoreMapNoWriteBarrier(result, HeapNumberMapConstant()); | 1237 Heap::RootListIndex heap_map_index = |
| 1238 mode == IMMUTABLE ? Heap::kHeapNumberMapRootIndex |
| 1239 : Heap::kMutableHeapNumberMapRootIndex; |
| 1240 Node* map = LoadRoot(heap_map_index); |
| 1241 StoreMapNoWriteBarrier(result, map); |
| 1238 return result; | 1242 return result; |
| 1239 } | 1243 } |
| 1240 | 1244 |
| 1241 Node* CodeStubAssembler::AllocateHeapNumberWithValue(Node* value) { | 1245 Node* CodeStubAssembler::AllocateHeapNumberWithValue(Node* value, |
| 1242 Node* result = AllocateHeapNumber(); | 1246 MutableMode mode) { |
| 1247 Node* result = AllocateHeapNumber(mode); |
| 1243 StoreHeapNumberValue(result, value); | 1248 StoreHeapNumberValue(result, value); |
| 1244 return result; | 1249 return result; |
| 1245 } | 1250 } |
| 1246 | 1251 |
| 1247 Node* CodeStubAssembler::AllocateSeqOneByteString(int length) { | 1252 Node* CodeStubAssembler::AllocateSeqOneByteString(int length) { |
| 1248 Node* result = Allocate(SeqOneByteString::SizeFor(length)); | 1253 Node* result = Allocate(SeqOneByteString::SizeFor(length)); |
| 1249 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex)); | 1254 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex)); |
| 1250 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, | 1255 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, |
| 1251 SmiConstant(Smi::FromInt(length))); | 1256 SmiConstant(Smi::FromInt(length))); |
| 1252 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldOffset, | 1257 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldOffset, |
| (...skipping 3002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4255 TailCallStub(descriptor, handler, p->context, receiver, fake_name, p->slot, | 4260 TailCallStub(descriptor, handler, p->context, receiver, fake_name, p->slot, |
| 4256 p->vector); | 4261 p->vector); |
| 4257 } | 4262 } |
| 4258 Bind(&miss); | 4263 Bind(&miss); |
| 4259 { | 4264 { |
| 4260 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot, | 4265 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot, |
| 4261 p->vector); | 4266 p->vector); |
| 4262 } | 4267 } |
| 4263 } | 4268 } |
| 4264 | 4269 |
| 4270 Node* CodeStubAssembler::PrepareValueForWrite(Node* value, |
| 4271 Representation representation, |
| 4272 Label* bailout) { |
| 4273 if (representation.IsDouble()) { |
| 4274 Variable var_value(this, MachineRepresentation::kFloat64); |
| 4275 Label if_smi(this), if_heap_object(this), done(this); |
| 4276 Branch(WordIsSmi(value), &if_smi, &if_heap_object); |
| 4277 Bind(&if_smi); |
| 4278 { |
| 4279 var_value.Bind(SmiToFloat64(value)); |
| 4280 Goto(&done); |
| 4281 } |
| 4282 Bind(&if_heap_object); |
| 4283 { |
| 4284 GotoUnless( |
| 4285 Word32Equal(LoadInstanceType(value), Int32Constant(HEAP_NUMBER_TYPE)), |
| 4286 bailout); |
| 4287 var_value.Bind(LoadHeapNumberValue(value)); |
| 4288 Goto(&done); |
| 4289 } |
| 4290 Bind(&done); |
| 4291 value = var_value.value(); |
| 4292 } else if (representation.IsHeapObject()) { |
| 4293 // Field type is checked by the handler, here we only check if the value |
| 4294 // is a heap object. |
| 4295 GotoIf(WordIsSmi(value), bailout); |
| 4296 } else if (representation.IsSmi()) { |
| 4297 GotoUnless(WordIsSmi(value), bailout); |
| 4298 } else { |
| 4299 DCHECK(representation.IsTagged()); |
| 4300 } |
| 4301 return value; |
| 4302 } |
| 4303 |
| 4304 void CodeStubAssembler::StoreNamedField(Node* object, FieldIndex index, |
| 4305 Representation representation, |
| 4306 Node* value, bool transition_to_field) { |
| 4307 DCHECK_EQ(index.is_double(), representation.IsDouble()); |
| 4308 |
| 4309 bool store_value_as_double = representation.IsDouble(); |
| 4310 int offset = index.offset(); |
| 4311 Node* property_storage = object; |
| 4312 if (!index.is_inobject()) { |
| 4313 property_storage = LoadProperties(object); |
| 4314 } |
| 4315 |
| 4316 if (representation.IsDouble()) { |
| 4317 if (!FLAG_unbox_double_fields || !index.is_inobject()) { |
| 4318 if (transition_to_field) { |
| 4319 Node* heap_number = AllocateHeapNumberWithValue(value, MUTABLE); |
| 4320 // Store the new mutable heap number into the object. |
| 4321 value = heap_number; |
| 4322 store_value_as_double = false; |
| 4323 } else { |
| 4324 // Load the heap number. |
| 4325 property_storage = LoadObjectField(property_storage, offset); |
| 4326 // Store the double value into it. |
| 4327 offset = HeapNumber::kValueOffset; |
| 4328 } |
| 4329 } |
| 4330 } |
| 4331 |
| 4332 if (store_value_as_double) { |
| 4333 StoreObjectFieldNoWriteBarrier(property_storage, offset, value, |
| 4334 MachineRepresentation::kFloat64); |
| 4335 } else { |
| 4336 StoreObjectField(property_storage, offset, value); |
| 4337 } |
| 4338 } |
| 4339 |
| 4265 Node* CodeStubAssembler::EnumLength(Node* map) { | 4340 Node* CodeStubAssembler::EnumLength(Node* map) { |
| 4266 Node* bitfield_3 = LoadMapBitField3(map); | 4341 Node* bitfield_3 = LoadMapBitField3(map); |
| 4267 Node* enum_length = BitFieldDecode<Map::EnumLengthBits>(bitfield_3); | 4342 Node* enum_length = BitFieldDecode<Map::EnumLengthBits>(bitfield_3); |
| 4268 return SmiTag(enum_length); | 4343 return SmiTag(enum_length); |
| 4269 } | 4344 } |
| 4270 | 4345 |
| 4271 void CodeStubAssembler::CheckEnumCache(Node* receiver, Label* use_cache, | 4346 void CodeStubAssembler::CheckEnumCache(Node* receiver, Label* use_cache, |
| 4272 Label* use_runtime) { | 4347 Label* use_runtime) { |
| 4273 Variable current_js_object(this, MachineRepresentation::kTagged); | 4348 Variable current_js_object(this, MachineRepresentation::kTagged); |
| 4274 current_js_object.Bind(receiver); | 4349 current_js_object.Bind(receiver); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4342 Heap::kTheHoleValueRootIndex); | 4417 Heap::kTheHoleValueRootIndex); |
| 4343 | 4418 |
| 4344 // Store the WeakCell in the feedback vector. | 4419 // Store the WeakCell in the feedback vector. |
| 4345 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, | 4420 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, |
| 4346 CodeStubAssembler::SMI_PARAMETERS); | 4421 CodeStubAssembler::SMI_PARAMETERS); |
| 4347 return cell; | 4422 return cell; |
| 4348 } | 4423 } |
| 4349 | 4424 |
| 4350 } // namespace internal | 4425 } // namespace internal |
| 4351 } // namespace v8 | 4426 } // namespace v8 |
| OLD | NEW |