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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 14284010: Introduce HObjectAccess, which is used by LoadNamedField and StoreNamedField to denote what parts (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use BitField utility instead of C-language bitfield for portion and offset in HObjectAccess. Created 7 years, 7 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/arm/lithium-arm.cc ('k') | src/hydrogen.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 351
352 352
353 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { 353 Handle<Code> FastCloneShallowArrayStub::GenerateCode() {
354 return DoGenerateCode(this); 354 return DoGenerateCode(this);
355 } 355 }
356 356
357 357
358 template <> 358 template <>
359 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { 359 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() {
360 Zone* zone = this->zone(); 360 Zone* zone = this->zone();
361 Factory* factory = isolate()->factory();
362 HValue* undefined = graph()->GetConstantUndefined(); 361 HValue* undefined = graph()->GetConstantUndefined();
363 362
364 HInstruction* boilerplate = 363 HInstruction* boilerplate =
365 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), 364 AddInstruction(new(zone) HLoadKeyed(GetParameter(0),
366 GetParameter(1), 365 GetParameter(1),
367 NULL, 366 NULL,
368 FAST_ELEMENTS)); 367 FAST_ELEMENTS));
369 368
370 IfBuilder checker(this); 369 IfBuilder checker(this);
371 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); 370 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined);
372 checker.And(); 371 checker.And();
373 372
374 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; 373 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize;
375 HValue* boilerplate_size = 374 HValue* boilerplate_size =
376 AddInstruction(new(zone) HInstanceSize(boilerplate)); 375 AddInstruction(new(zone) HInstanceSize(boilerplate));
377 HValue* size_in_words = 376 HValue* size_in_words =
378 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2, 377 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2,
379 Representation::Integer32())); 378 Representation::Integer32()));
380 checker.IfCompare(boilerplate_size, size_in_words, Token::EQ); 379 checker.IfCompare(boilerplate_size, size_in_words, Token::EQ);
381 checker.Then(); 380 checker.Then();
382 381
383 HValue* size_in_bytes = 382 HValue* size_in_bytes =
384 AddInstruction(new(zone) HConstant(size, Representation::Integer32())); 383 AddInstruction(new(zone) HConstant(size, Representation::Integer32()));
385 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; 384 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE;
386 if (FLAG_pretenure_literals) { 385 if (FLAG_pretenure_literals) {
387 flags = static_cast<HAllocate::Flags>( 386 flags = static_cast<HAllocate::Flags>(
388 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); 387 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
389 } 388 }
390 HInstruction* object = 389
391 AddInstruction(new(zone) HAllocate(context(), 390 HInstruction* object = AddInstruction(new(zone)
392 size_in_bytes, 391 HAllocate(context(), size_in_bytes, HType::JSObject(), flags));
393 HType::JSObject(),
394 flags));
395 392
396 for (int i = 0; i < size; i += kPointerSize) { 393 for (int i = 0; i < size; i += kPointerSize) {
397 HInstruction* value = 394 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i);
398 AddInstruction(new(zone) HLoadNamedField( 395 AddStore(object, access, AddLoad(boilerplate, access));
399 boilerplate, true, Representation::Tagged(), i));
400 AddInstruction(new(zone) HStoreNamedField(object,
401 factory->empty_string(),
402 value, true,
403 Representation::Tagged(), i));
404 } 396 }
405 397
406 checker.ElseDeopt(); 398 checker.ElseDeopt();
407 return object; 399 return object;
408 } 400 }
409 401
410 402
411 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { 403 Handle<Code> FastCloneShallowObjectStub::GenerateCode() {
412 return DoGenerateCode(this); 404 return DoGenerateCode(this);
413 } 405 }
414 406
415 407
416 template <> 408 template <>
417 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { 409 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
418 HInstruction* load = BuildUncheckedMonomorphicElementAccess( 410 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
419 GetParameter(0), GetParameter(1), NULL, NULL, 411 GetParameter(0), GetParameter(1), NULL, NULL,
420 casted_stub()->is_js_array(), casted_stub()->elements_kind(), 412 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
421 false, NEVER_RETURN_HOLE, STANDARD_STORE, Representation::Tagged()); 413 false, NEVER_RETURN_HOLE, STANDARD_STORE, Representation::Tagged());
422 return load; 414 return load;
423 } 415 }
424 416
425 417
426 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { 418 Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
427 return DoGenerateCode(this); 419 return DoGenerateCode(this);
428 } 420 }
429 421
430 422
431 template<> 423 template<>
432 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { 424 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() {
433 Representation representation = casted_stub()->representation(); 425 HObjectAccess access = casted_stub()->is_inobject() ?
434 HInstruction* load = AddInstruction(DoBuildLoadNamedField( 426 HObjectAccess::ForJSObjectOffset(casted_stub()->offset()) :
435 GetParameter(0), casted_stub()->is_inobject(), 427 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset());
436 representation, casted_stub()->offset())); 428 return AddInstruction(BuildLoadNamedField(GetParameter(0), access,
437 return load; 429 casted_stub()->representation()));
438 } 430 }
439 431
440 432
441 Handle<Code> LoadFieldStub::GenerateCode() { 433 Handle<Code> LoadFieldStub::GenerateCode() {
442 return DoGenerateCode(this); 434 return DoGenerateCode(this);
443 } 435 }
444 436
445 437
446 template<> 438 template<>
447 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { 439 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() {
448 Representation representation = casted_stub()->representation(); 440 HObjectAccess access = casted_stub()->is_inobject() ?
449 HInstruction* load = AddInstruction(DoBuildLoadNamedField( 441 HObjectAccess::ForJSObjectOffset(casted_stub()->offset()) :
450 GetParameter(0), casted_stub()->is_inobject(), 442 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset());
451 representation, casted_stub()->offset())); 443 return AddInstruction(BuildLoadNamedField(GetParameter(0), access,
452 return load; 444 casted_stub()->representation()));
453 } 445 }
454 446
455 447
456 Handle<Code> KeyedLoadFieldStub::GenerateCode() { 448 Handle<Code> KeyedLoadFieldStub::GenerateCode() {
457 return DoGenerateCode(this); 449 return DoGenerateCode(this);
458 } 450 }
459 451
460 452
461 template <> 453 template <>
462 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { 454 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
(...skipping 17 matching lines...) Expand all
480 Zone* zone = this->zone(); 472 Zone* zone = this->zone();
481 473
482 HValue* js_array = GetParameter(0); 474 HValue* js_array = GetParameter(0);
483 HValue* map = GetParameter(1); 475 HValue* map = GetParameter(1);
484 476
485 info()->MarkAsSavesCallerDoubles(); 477 info()->MarkAsSavesCallerDoubles();
486 478
487 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); 479 AddInstruction(new(zone) HTrapAllocationMemento(js_array));
488 480
489 HInstruction* array_length = 481 HInstruction* array_length =
490 AddInstruction(HLoadNamedField::NewArrayLength( 482 AddLoad(js_array, HObjectAccess::ForArrayLength());
491 zone, js_array, js_array, HType::Smi())); 483 array_length->set_type(HType::Smi());
492 484
493 ElementsKind to_kind = casted_stub()->to_kind(); 485 ElementsKind to_kind = casted_stub()->to_kind();
494 BuildNewSpaceArrayCheck(array_length, to_kind); 486 BuildNewSpaceArrayCheck(array_length, to_kind);
495 487
496 IfBuilder if_builder(this); 488 IfBuilder if_builder(this);
497 489
498 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); 490 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ);
499 if_builder.Then(); 491 if_builder.Then();
500 492
501 // Nothing to do, just change the map. 493 // Nothing to do, just change the map.
502 494
503 if_builder.Else(); 495 if_builder.Else();
504 496
505 HInstruction* elements = AddLoadElements(js_array); 497 HInstruction* elements = AddLoadElements(js_array);
506 498
507 HInstruction* elements_length = 499 HInstruction* elements_length =
508 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); 500 AddInstruction(new(zone) HFixedArrayBaseLength(elements));
509 501
510 HValue* new_elements = 502 HValue* new_elements =
511 BuildAllocateAndInitializeElements(context(), to_kind, elements_length); 503 BuildAllocateAndInitializeElements(context(), to_kind, elements_length);
512 504
513 BuildCopyElements(context(), elements, 505 BuildCopyElements(context(), elements,
514 casted_stub()->from_kind(), new_elements, 506 casted_stub()->from_kind(), new_elements,
515 to_kind, array_length, elements_length); 507 to_kind, array_length, elements_length);
516 508
517 Factory* factory = isolate()->factory(); 509 AddStore(js_array, HObjectAccess::ForElementsPointer(), new_elements);
518
519 AddInstruction(new(zone) HStoreNamedField(js_array,
520 factory->elements_field_string(),
521 new_elements, true,
522 Representation::Tagged(),
523 JSArray::kElementsOffset));
524 510
525 if_builder.End(); 511 if_builder.End();
526 512
527 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(), 513 AddStore(js_array, HObjectAccess::ForMap(), map);
528 map, true, 514
529 Representation::Tagged(),
530 JSArray::kMapOffset));
531 return js_array; 515 return js_array;
532 } 516 }
533 517
534 518
535 Handle<Code> TransitionElementsKindStub::GenerateCode() { 519 Handle<Code> TransitionElementsKindStub::GenerateCode() {
536 return DoGenerateCode(this); 520 return DoGenerateCode(this);
537 } 521 }
538 522
539 523
540 template <> 524 template <>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 ? graph()->GetConstantSmi1() 678 ? graph()->GetConstantSmi1()
695 : graph()->GetConstantUndefined(); 679 : graph()->GetConstantUndefined();
696 } 680 }
697 681
698 682
699 Handle<Code> CompareNilICStub::GenerateCode() { 683 Handle<Code> CompareNilICStub::GenerateCode() {
700 return DoGenerateCode(this); 684 return DoGenerateCode(this);
701 } 685 }
702 686
703 } } // namespace v8::internal 687 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698