OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/ic/call-optimization.h" | 7 #include "src/ic/call-optimization.h" |
8 #include "src/ic/handler-compiler.h" | 8 #include "src/ic/handler-compiler.h" |
9 #include "src/ic/ic.h" | 9 #include "src/ic/ic.h" |
10 #include "src/ic/ic-inl.h" | 10 #include "src/ic/ic-inl.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 Handle<Name> name, Handle<JSFunction> getter) { | 302 Handle<Name> name, Handle<JSFunction> getter) { |
303 Frontend(receiver(), name); | 303 Frontend(receiver(), name); |
304 GenerateLoadViaGetter(masm(), type(), receiver(), getter); | 304 GenerateLoadViaGetter(masm(), type(), receiver(), getter); |
305 return GetCode(kind(), Code::FAST, name); | 305 return GetCode(kind(), Code::FAST, name); |
306 } | 306 } |
307 | 307 |
308 | 308 |
309 // TODO(verwaest): Cleanup. holder() is actually the receiver. | 309 // TODO(verwaest): Cleanup. holder() is actually the receiver. |
310 Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition( | 310 Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition( |
311 Handle<Map> transition, Handle<Name> name) { | 311 Handle<Map> transition, Handle<Name> name) { |
312 Label miss, slow; | 312 Label miss; |
313 | 313 |
314 // Ensure no transitions to deprecated maps are followed. | 314 // Ensure no transitions to deprecated maps are followed. |
315 __ CheckMapDeprecated(transition, scratch1(), &miss); | 315 __ CheckMapDeprecated(transition, scratch1(), &miss); |
316 | 316 |
317 // Check that we are allowed to write this. | 317 // Check that we are allowed to write this. |
318 bool is_nonexistent = holder()->map() == transition->GetBackPointer(); | 318 bool is_nonexistent = holder()->map() == transition->GetBackPointer(); |
319 if (is_nonexistent) { | 319 if (is_nonexistent) { |
320 // Find the top object. | 320 // Find the top object. |
321 Handle<JSObject> last; | 321 Handle<JSObject> last; |
322 PrototypeIterator iter(isolate(), holder()); | 322 PrototypeIterator iter(isolate(), holder()); |
323 while (!iter.IsAtEnd()) { | 323 while (!iter.IsAtEnd()) { |
324 last = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | 324 last = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); |
325 iter.Advance(); | 325 iter.Advance(); |
326 } | 326 } |
327 if (!last.is_null()) set_holder(last); | 327 if (!last.is_null()) set_holder(last); |
328 NonexistentFrontendHeader(name, &miss, scratch1(), scratch2()); | 328 NonexistentFrontendHeader(name, &miss, scratch1(), scratch2()); |
329 } else { | 329 } else { |
330 FrontendHeader(receiver(), name, &miss); | 330 FrontendHeader(receiver(), name, &miss); |
331 DCHECK(holder()->HasFastProperties()); | 331 DCHECK(holder()->HasFastProperties()); |
332 } | 332 } |
333 | 333 |
334 GenerateStoreTransition(transition, name, receiver(), this->name(), value(), | 334 int descriptor = transition->LastAdded(); |
335 scratch1(), scratch2(), scratch3(), &miss, &slow); | 335 DescriptorArray* descriptors = transition->instance_descriptors(); |
| 336 PropertyDetails details = descriptors->GetDetails(descriptor); |
| 337 Representation representation = details.representation(); |
| 338 DCHECK(!representation.IsNone()); |
| 339 |
| 340 // Stub is never generated for objects that require access checks. |
| 341 DCHECK(!transition->is_access_check_needed()); |
| 342 |
| 343 // Call to respective StoreTransitionStub. |
| 344 if (details.type() == CONSTANT) { |
| 345 GenerateConstantCheck(descriptors->GetValue(descriptor), value(), &miss); |
| 346 |
| 347 GenerateRestoreNameAndMap(name, transition); |
| 348 StoreTransitionStub stub(isolate()); |
| 349 GenerateTailCall(masm(), stub.GetCode()); |
| 350 |
| 351 } else { |
| 352 if (representation.IsHeapObject()) { |
| 353 GenerateFieldTypeChecks(descriptors->GetFieldType(descriptor), value(), |
| 354 &miss); |
| 355 } |
| 356 StoreTransitionStub::StoreMode store_mode = |
| 357 Map::cast(transition->GetBackPointer())->unused_property_fields() == 0 |
| 358 ? StoreTransitionStub::ExtendStorageAndStoreMapAndValue |
| 359 : StoreTransitionStub::StoreMapAndValue; |
| 360 |
| 361 GenerateRestoreNameAndMap(name, transition); |
| 362 StoreTransitionStub stub(isolate(), |
| 363 FieldIndex::ForDescriptor(*transition, descriptor), |
| 364 representation, store_mode); |
| 365 GenerateTailCall(masm(), stub.GetCode()); |
| 366 } |
336 | 367 |
337 GenerateRestoreName(&miss, name); | 368 GenerateRestoreName(&miss, name); |
338 TailCallBuiltin(masm(), MissBuiltin(kind())); | 369 TailCallBuiltin(masm(), MissBuiltin(kind())); |
339 | 370 |
340 GenerateRestoreName(&slow, name); | |
341 TailCallBuiltin(masm(), SlowBuiltin(kind())); | |
342 return GetCode(kind(), Code::FAST, name); | 371 return GetCode(kind(), Code::FAST, name); |
343 } | 372 } |
344 | 373 |
345 | 374 |
346 Handle<Code> NamedStoreHandlerCompiler::CompileStoreField(LookupIterator* it) { | 375 Handle<Code> NamedStoreHandlerCompiler::CompileStoreField(LookupIterator* it) { |
347 Label miss; | 376 Label miss; |
348 GenerateStoreField(it, value(), &miss); | 377 DCHECK(it->representation().IsHeapObject()); |
| 378 |
| 379 GenerateFieldTypeChecks(*it->GetFieldType(), value(), &miss); |
| 380 StoreFieldStub stub(isolate(), it->GetFieldIndex(), it->representation()); |
| 381 GenerateTailCall(masm(), stub.GetCode()); |
| 382 |
349 __ bind(&miss); | 383 __ bind(&miss); |
350 TailCallBuiltin(masm(), MissBuiltin(kind())); | 384 TailCallBuiltin(masm(), MissBuiltin(kind())); |
351 return GetCode(kind(), Code::FAST, it->name()); | 385 return GetCode(kind(), Code::FAST, it->name()); |
352 } | 386 } |
353 | 387 |
354 | 388 |
355 Handle<Code> NamedStoreHandlerCompiler::CompileStoreViaSetter( | 389 Handle<Code> NamedStoreHandlerCompiler::CompileStoreViaSetter( |
356 Handle<JSObject> object, Handle<Name> name, Handle<JSFunction> setter) { | 390 Handle<JSObject> object, Handle<Name> name, Handle<JSFunction> setter) { |
357 Frontend(receiver(), name); | 391 Frontend(receiver(), name); |
358 GenerateStoreViaSetter(masm(), type(), receiver(), setter); | 392 GenerateStoreViaSetter(masm(), type(), receiver(), setter); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 DCHECK(elements_kind == DICTIONARY_ELEMENTS); | 435 DCHECK(elements_kind == DICTIONARY_ELEMENTS); |
402 cached_stub = LoadDictionaryElementStub(isolate()).GetCode(); | 436 cached_stub = LoadDictionaryElementStub(isolate()).GetCode(); |
403 } | 437 } |
404 } | 438 } |
405 | 439 |
406 handlers->Add(cached_stub); | 440 handlers->Add(cached_stub); |
407 } | 441 } |
408 } | 442 } |
409 } | 443 } |
410 } // namespace v8::internal | 444 } // namespace v8::internal |
OLD | NEW |