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

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: Make constructor of HObjectAccess and HObjectAccess::Portion private. 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
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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 333
334 334
335 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { 335 Handle<Code> FastCloneShallowArrayStub::GenerateCode() {
336 return DoGenerateCode(this); 336 return DoGenerateCode(this);
337 } 337 }
338 338
339 339
340 template <> 340 template <>
341 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { 341 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() {
342 Zone* zone = this->zone(); 342 Zone* zone = this->zone();
343 Factory* factory = isolate()->factory();
344 HValue* undefined = graph()->GetConstantUndefined(); 343 HValue* undefined = graph()->GetConstantUndefined();
345 344
346 HInstruction* boilerplate = 345 HInstruction* boilerplate =
347 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), 346 AddInstruction(new(zone) HLoadKeyed(GetParameter(0),
348 GetParameter(1), 347 GetParameter(1),
349 NULL, 348 NULL,
350 FAST_ELEMENTS)); 349 FAST_ELEMENTS));
351 350
352 IfBuilder checker(this); 351 IfBuilder checker(this);
353 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); 352 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined);
354 checker.And(); 353 checker.And();
355 354
356 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; 355 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize;
357 HValue* boilerplate_size = 356 HValue* boilerplate_size =
358 AddInstruction(new(zone) HInstanceSize(boilerplate)); 357 AddInstruction(new(zone) HInstanceSize(boilerplate));
359 HValue* size_in_words = 358 HValue* size_in_words =
360 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2, 359 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2,
361 Representation::Integer32())); 360 Representation::Integer32()));
362 checker.IfCompare(boilerplate_size, size_in_words, Token::EQ); 361 checker.IfCompare(boilerplate_size, size_in_words, Token::EQ);
363 checker.Then(); 362 checker.Then();
364 363
365 HValue* size_in_bytes = 364 HValue* size_in_bytes =
366 AddInstruction(new(zone) HConstant(size, Representation::Integer32())); 365 AddInstruction(new(zone) HConstant(size, Representation::Integer32()));
367 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; 366 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE;
368 if (FLAG_pretenure_literals) { 367 if (FLAG_pretenure_literals) {
369 flags = static_cast<HAllocate::Flags>( 368 flags = static_cast<HAllocate::Flags>(
370 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); 369 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
371 } 370 }
372 HInstruction* object = 371
373 AddInstruction(new(zone) HAllocate(context(), 372 HInstruction* object = AddInstruction(new(zone)
374 size_in_bytes, 373 HAllocate(context(), size_in_bytes, HType::JSObject(), flags));
375 HType::JSObject(),
376 flags));
377 374
378 for (int i = 0; i < size; i += kPointerSize) { 375 for (int i = 0; i < size; i += kPointerSize) {
379 HInstruction* value = 376 HObjectAccess access = HObjectAccess::ForOffset(i);
380 AddInstruction(new(zone) HLoadNamedField( 377 HInstruction* value = AddLoad(boilerplate, access);
381 boilerplate, true, Representation::Tagged(), i)); 378 AddStore(object, access, value);
382 AddInstruction(new(zone) HStoreNamedField(object,
383 factory->empty_string(),
384 value, true,
385 Representation::Tagged(), i));
386 } 379 }
387 380
388 checker.ElseDeopt(); 381 checker.ElseDeopt();
389 return object; 382 return object;
390 } 383 }
391 384
392 385
393 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { 386 Handle<Code> FastCloneShallowObjectStub::GenerateCode() {
394 return DoGenerateCode(this); 387 return DoGenerateCode(this);
395 } 388 }
396 389
397 390
398 template <> 391 template <>
399 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { 392 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
400 HInstruction* load = BuildUncheckedMonomorphicElementAccess( 393 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
401 GetParameter(0), GetParameter(1), NULL, NULL, 394 GetParameter(0), GetParameter(1), NULL, NULL,
402 casted_stub()->is_js_array(), casted_stub()->elements_kind(), 395 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
403 false, STANDARD_STORE, Representation::Tagged()); 396 false, STANDARD_STORE, Representation::Tagged());
404 return load; 397 return load;
405 } 398 }
406 399
407 400
408 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { 401 Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
409 return DoGenerateCode(this); 402 return DoGenerateCode(this);
410 } 403 }
411 404
412 405
413 template<> 406 template<>
414 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { 407 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() {
415 Representation representation = casted_stub()->representation(); 408 HObjectAccess access = HObjectAccess::For(
416 HInstruction* load = AddInstruction(new(zone()) HLoadNamedField( 409 casted_stub()->is_inobject(), casted_stub()->offset());
417 GetParameter(0), casted_stub()->is_inobject(), 410 HValue *obj = GetParameter(0);
418 representation, casted_stub()->offset())); 411 return AddLoad(obj, access, NULL, casted_stub()->representation());
419 return load;
420 } 412 }
421 413
422 414
423 Handle<Code> LoadFieldStub::GenerateCode() { 415 Handle<Code> LoadFieldStub::GenerateCode() {
424 return DoGenerateCode(this); 416 return DoGenerateCode(this);
425 } 417 }
426 418
427 419
428 template<> 420 template<>
429 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { 421 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() {
430 Representation representation = casted_stub()->representation(); 422 HObjectAccess access = HObjectAccess::For(
431 HInstruction* load = AddInstruction(new(zone()) HLoadNamedField( 423 casted_stub()->is_inobject(), casted_stub()->offset());
432 GetParameter(0), casted_stub()->is_inobject(), 424 HValue *obj = GetParameter(0);
433 representation, casted_stub()->offset())); 425 return AddLoad(obj, access, NULL, casted_stub()->representation());
434 return load;
435 } 426 }
436 427
437 428
438 Handle<Code> KeyedLoadFieldStub::GenerateCode() { 429 Handle<Code> KeyedLoadFieldStub::GenerateCode() {
439 return DoGenerateCode(this); 430 return DoGenerateCode(this);
440 } 431 }
441 432
442 433
443 template <> 434 template <>
444 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { 435 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
(...skipping 16 matching lines...) Expand all
461 Zone* zone = this->zone(); 452 Zone* zone = this->zone();
462 453
463 HValue* js_array = GetParameter(0); 454 HValue* js_array = GetParameter(0);
464 HValue* map = GetParameter(1); 455 HValue* map = GetParameter(1);
465 456
466 info()->MarkAsSavesCallerDoubles(); 457 info()->MarkAsSavesCallerDoubles();
467 458
468 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); 459 AddInstruction(new(zone) HTrapAllocationMemento(js_array));
469 460
470 HInstruction* array_length = 461 HInstruction* array_length =
471 AddInstruction(HLoadNamedField::NewArrayLength( 462 AddLoad(js_array, HObjectAccess::ForArrayLength());
472 zone, js_array, js_array, HType::Smi())); 463 array_length->set_type(HType::Smi());
473 464
474 ElementsKind to_kind = casted_stub()->to_kind(); 465 ElementsKind to_kind = casted_stub()->to_kind();
475 BuildNewSpaceArrayCheck(array_length, to_kind); 466 BuildNewSpaceArrayCheck(array_length, to_kind);
476 467
477 IfBuilder if_builder(this); 468 IfBuilder if_builder(this);
478 469
479 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); 470 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ);
480 if_builder.Then(); 471 if_builder.Then();
481 472
482 // Nothing to do, just change the map. 473 // Nothing to do, just change the map.
483 474
484 if_builder.Else(); 475 if_builder.Else();
485 476
486 HInstruction* elements = AddLoadElements(js_array); 477 HInstruction* elements = AddLoadElements(js_array);
487 478
488 HInstruction* elements_length = 479 HInstruction* elements_length =
489 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); 480 AddInstruction(new(zone) HFixedArrayBaseLength(elements));
490 481
491 HValue* new_elements = 482 HValue* new_elements =
492 BuildAllocateAndInitializeElements(context(), to_kind, elements_length); 483 BuildAllocateAndInitializeElements(context(), to_kind, elements_length);
493 484
494 BuildCopyElements(context(), elements, 485 BuildCopyElements(context(), elements,
495 casted_stub()->from_kind(), new_elements, 486 casted_stub()->from_kind(), new_elements,
496 to_kind, array_length, elements_length); 487 to_kind, array_length, elements_length);
497 488
498 Factory* factory = isolate()->factory(); 489 AddStore(js_array, HObjectAccess::ForElementsPointer(), new_elements);
499
500 AddInstruction(new(zone) HStoreNamedField(js_array,
501 factory->elements_field_string(),
502 new_elements, true,
503 Representation::Tagged(),
504 JSArray::kElementsOffset));
505 490
506 if_builder.End(); 491 if_builder.End();
507 492
508 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(), 493 AddStore(js_array, HObjectAccess::ForMap(), map);
509 map, true, 494
510 Representation::Tagged(),
511 JSArray::kMapOffset));
512 return js_array; 495 return js_array;
513 } 496 }
514 497
515 498
516 Handle<Code> TransitionElementsKindStub::GenerateCode() { 499 Handle<Code> TransitionElementsKindStub::GenerateCode() {
517 return DoGenerateCode(this); 500 return DoGenerateCode(this);
518 } 501 }
519 502
520 503
521 template <> 504 template <>
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 ? graph()->GetConstantSmi1() 646 ? graph()->GetConstantSmi1()
664 : graph()->GetConstantUndefined(); 647 : graph()->GetConstantUndefined();
665 } 648 }
666 649
667 650
668 Handle<Code> CompareNilICStub::GenerateCode() { 651 Handle<Code> CompareNilICStub::GenerateCode() {
669 return DoGenerateCode(this); 652 return DoGenerateCode(this);
670 } 653 }
671 654
672 } } // namespace v8::internal 655 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen.h » ('j') | src/hydrogen.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698