Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(630)

Side by Side Diff: src/ic/x64/handler-compiler-x64.cc

Issue 609463003: Hydrogenize (and share) part of StoreTransition handler as a StoreTransitionStub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebasing Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ic/mips64/handler-compiler-mips64.cc ('k') | src/ic/x87/handler-compiler-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/ic/call-optimization.h" 9 #include "src/ic/call-optimization.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 317
318 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label, 318 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label,
319 Handle<Name> name) { 319 Handle<Name> name) {
320 if (!label->is_unused()) { 320 if (!label->is_unused()) {
321 __ bind(label); 321 __ bind(label);
322 __ Move(this->name(), name); 322 __ Move(this->name(), name);
323 } 323 }
324 } 324 }
325 325
326 326
327 // Receiver_reg is preserved on jumps to miss_label, but may be destroyed if 327 void NamedStoreHandlerCompiler::GenerateRestoreNameAndMap(
328 // store is successful. 328 Handle<Name> name, Handle<Map> transition) {
329 void NamedStoreHandlerCompiler::GenerateStoreTransition( 329 __ Move(this->name(), name);
330 Handle<Map> transition, Handle<Name> name, Register receiver_reg, 330 __ Move(StoreTransitionDescriptor::MapRegister(), transition);
331 Register storage_reg, Register value_reg, Register scratch1,
332 Register scratch2, Register unused, Label* miss_label, Label* slow) {
333 int descriptor = transition->LastAdded();
334 DescriptorArray* descriptors = transition->instance_descriptors();
335 PropertyDetails details = descriptors->GetDetails(descriptor);
336 Representation representation = details.representation();
337 DCHECK(!representation.IsNone());
338
339 if (details.type() == CONSTANT) {
340 Handle<Object> constant(descriptors->GetValue(descriptor), isolate());
341 __ Cmp(value_reg, constant);
342 __ j(not_equal, miss_label);
343 } else if (representation.IsSmi()) {
344 __ JumpIfNotSmi(value_reg, miss_label);
345 } else if (representation.IsHeapObject()) {
346 __ JumpIfSmi(value_reg, miss_label);
347 HeapType* field_type = descriptors->GetFieldType(descriptor);
348 HeapType::Iterator<Map> it = field_type->Classes();
349 if (!it.Done()) {
350 Label do_store;
351 while (true) {
352 __ CompareMap(value_reg, it.Current());
353 it.Advance();
354 if (it.Done()) {
355 __ j(not_equal, miss_label);
356 break;
357 }
358 __ j(equal, &do_store, Label::kNear);
359 }
360 __ bind(&do_store);
361 }
362 } else if (representation.IsDouble()) {
363 Label do_store, heap_number;
364 __ AllocateHeapNumber(storage_reg, scratch1, slow, MUTABLE);
365
366 __ JumpIfNotSmi(value_reg, &heap_number);
367 __ SmiToInteger32(scratch1, value_reg);
368 __ Cvtlsi2sd(xmm0, scratch1);
369 __ jmp(&do_store);
370
371 __ bind(&heap_number);
372 __ CheckMap(value_reg, isolate()->factory()->heap_number_map(), miss_label,
373 DONT_DO_SMI_CHECK);
374 __ movsd(xmm0, FieldOperand(value_reg, HeapNumber::kValueOffset));
375
376 __ bind(&do_store);
377 __ movsd(FieldOperand(storage_reg, HeapNumber::kValueOffset), xmm0);
378 }
379
380 // Stub never generated for objects that require access checks.
381 DCHECK(!transition->is_access_check_needed());
382
383 // Perform map transition for the receiver if necessary.
384 if (details.type() == FIELD &&
385 Map::cast(transition->GetBackPointer())->unused_property_fields() == 0) {
386 // The properties must be extended before we can store the value.
387 __ Move(ExtendStorageDescriptor::NameRegister(), name);
388 __ Move(ExtendStorageDescriptor::MapRegister(), transition);
389
390 ExtendStorageStub stub(isolate(),
391 FieldIndex::ForDescriptor(*transition, descriptor),
392 representation);
393 GenerateTailCall(masm(), stub.GetCode());
394 return;
395 }
396
397 // Update the map of the object.
398 __ Move(scratch1, transition);
399 __ movp(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1);
400
401 // Update the write barrier for the map field.
402 __ RecordWriteField(receiver_reg, HeapObject::kMapOffset, scratch1, scratch2,
403 kDontSaveFPRegs, OMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
404
405 if (details.type() == CONSTANT) {
406 DCHECK(value_reg.is(rax));
407 __ ret(0);
408 return;
409 }
410
411 int index = transition->instance_descriptors()->GetFieldIndex(
412 transition->LastAdded());
413
414 // Adjust for the number of properties stored in the object. Even in the
415 // face of a transition we can use the old map here because the size of the
416 // object and the number of in-object properties is not going to change.
417 index -= transition->inobject_properties();
418
419 // TODO(verwaest): Share this code as a code stub.
420 SmiCheck smi_check =
421 representation.IsTagged() ? INLINE_SMI_CHECK : OMIT_SMI_CHECK;
422 if (index < 0) {
423 // Set the property straight into the object.
424 int offset = transition->instance_size() + (index * kPointerSize);
425 if (representation.IsDouble()) {
426 __ movp(FieldOperand(receiver_reg, offset), storage_reg);
427 } else {
428 __ movp(FieldOperand(receiver_reg, offset), value_reg);
429 }
430
431 if (!representation.IsSmi()) {
432 // Update the write barrier for the array address.
433 if (!representation.IsDouble()) {
434 __ movp(storage_reg, value_reg);
435 }
436 __ RecordWriteField(receiver_reg, offset, storage_reg, scratch1,
437 kDontSaveFPRegs, EMIT_REMEMBERED_SET, smi_check);
438 }
439 } else {
440 // Write to the properties array.
441 int offset = index * kPointerSize + FixedArray::kHeaderSize;
442 // Get the properties array (optimistically).
443 __ movp(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset));
444 if (representation.IsDouble()) {
445 __ movp(FieldOperand(scratch1, offset), storage_reg);
446 } else {
447 __ movp(FieldOperand(scratch1, offset), value_reg);
448 }
449
450 if (!representation.IsSmi()) {
451 // Update the write barrier for the array address.
452 if (!representation.IsDouble()) {
453 __ movp(storage_reg, value_reg);
454 }
455 __ RecordWriteField(scratch1, offset, storage_reg, receiver_reg,
456 kDontSaveFPRegs, EMIT_REMEMBERED_SET, smi_check);
457 }
458 }
459
460 // Return the value (register rax).
461 DCHECK(value_reg.is(rax));
462 __ ret(0);
463 } 331 }
464 332
465 333
466 void NamedStoreHandlerCompiler::GenerateStoreField(LookupIterator* lookup, 334 void NamedStoreHandlerCompiler::GenerateConstantCheck(Object* constant,
467 Register value_reg, 335 Register value_reg,
468 Label* miss_label) { 336 Label* miss_label) {
469 DCHECK(lookup->representation().IsHeapObject()); 337 __ Cmp(value_reg, handle(constant, isolate()));
470 __ JumpIfSmi(value_reg, miss_label); 338 __ j(not_equal, miss_label);
471 HeapType::Iterator<Map> it = lookup->GetFieldType()->Classes();
472 Label do_store;
473 while (true) {
474 __ CompareMap(value_reg, it.Current());
475 it.Advance();
476 if (it.Done()) {
477 __ j(not_equal, miss_label);
478 break;
479 }
480 __ j(equal, &do_store, Label::kNear);
481 }
482 __ bind(&do_store);
483
484 StoreFieldStub stub(isolate(), lookup->GetFieldIndex(),
485 lookup->representation());
486 GenerateTailCall(masm(), stub.GetCode());
487 } 339 }
488 340
489 341
342 void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(HeapType* field_type,
343 Register value_reg,
344 Label* miss_label) {
345 __ JumpIfSmi(value_reg, miss_label);
346 HeapType::Iterator<Map> it = field_type->Classes();
347 if (!it.Done()) {
348 Label do_store;
349 while (true) {
350 __ CompareMap(value_reg, it.Current());
351 it.Advance();
352 if (it.Done()) {
353 __ j(not_equal, miss_label);
354 break;
355 }
356 __ j(equal, &do_store, Label::kNear);
357 }
358 __ bind(&do_store);
359 }
360 }
361
362
490 Register PropertyHandlerCompiler::CheckPrototypes( 363 Register PropertyHandlerCompiler::CheckPrototypes(
491 Register object_reg, Register holder_reg, Register scratch1, 364 Register object_reg, Register holder_reg, Register scratch1,
492 Register scratch2, Handle<Name> name, Label* miss, 365 Register scratch2, Handle<Name> name, Label* miss,
493 PrototypeCheckType check) { 366 PrototypeCheckType check) {
494 Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate())); 367 Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate()));
495 368
496 // Make sure there's no overlap between holder and object registers. 369 // Make sure there's no overlap between holder and object registers.
497 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); 370 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
498 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && 371 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) &&
499 !scratch2.is(scratch1)); 372 !scratch2.is(scratch1));
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // Return the generated code. 696 // Return the generated code.
824 return GetCode(kind(), Code::NORMAL, name); 697 return GetCode(kind(), Code::NORMAL, name);
825 } 698 }
826 699
827 700
828 #undef __ 701 #undef __
829 } 702 }
830 } // namespace v8::internal 703 } // namespace v8::internal
831 704
832 #endif // V8_TARGET_ARCH_X64 705 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ic/mips64/handler-compiler-mips64.cc ('k') | src/ic/x87/handler-compiler-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698