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

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: Split apart ForOffset into ForJSObjectOffset, ForJSArrayOffset, and ForFixedArrayOffset 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::ForJSObjectOffset(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 = casted_stub()->is_inobject() ?
416 HInstruction* load = AddInstruction(new(zone()) HLoadNamedField( 409 HObjectAccess::ForJSObjectOffset(casted_stub()->offset()) :
417 GetParameter(0), casted_stub()->is_inobject(), 410 HObjectAccess::For(false, casted_stub()->offset());
418 representation, casted_stub()->offset())); 411 return AddLoad(GetParameter(0), access, NULL,
419 return load; 412 casted_stub()->representation());
420 } 413 }
421 414
422 415
423 Handle<Code> LoadFieldStub::GenerateCode() { 416 Handle<Code> LoadFieldStub::GenerateCode() {
424 return DoGenerateCode(this); 417 return DoGenerateCode(this);
425 } 418 }
426 419
427 420
428 template<> 421 template<>
429 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { 422 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() {
430 Representation representation = casted_stub()->representation(); 423 HObjectAccess access = casted_stub()->is_inobject() ?
431 HInstruction* load = AddInstruction(new(zone()) HLoadNamedField( 424 HObjectAccess::ForJSObjectOffset(casted_stub()->offset()) :
432 GetParameter(0), casted_stub()->is_inobject(), 425 HObjectAccess::For(false, casted_stub()->offset());
433 representation, casted_stub()->offset())); 426 return AddLoad(GetParameter(0), access, NULL,
434 return load; 427 casted_stub()->representation());
435 } 428 }
436 429
437 430
438 Handle<Code> KeyedLoadFieldStub::GenerateCode() { 431 Handle<Code> KeyedLoadFieldStub::GenerateCode() {
439 return DoGenerateCode(this); 432 return DoGenerateCode(this);
440 } 433 }
441 434
442 435
443 template <> 436 template <>
444 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { 437 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
(...skipping 16 matching lines...) Expand all
461 Zone* zone = this->zone(); 454 Zone* zone = this->zone();
462 455
463 HValue* js_array = GetParameter(0); 456 HValue* js_array = GetParameter(0);
464 HValue* map = GetParameter(1); 457 HValue* map = GetParameter(1);
465 458
466 info()->MarkAsSavesCallerDoubles(); 459 info()->MarkAsSavesCallerDoubles();
467 460
468 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); 461 AddInstruction(new(zone) HTrapAllocationMemento(js_array));
469 462
470 HInstruction* array_length = 463 HInstruction* array_length =
471 AddInstruction(HLoadNamedField::NewArrayLength( 464 AddLoad(js_array, HObjectAccess::ForArrayLength());
472 zone, js_array, js_array, HType::Smi())); 465 array_length->set_type(HType::Smi());
473 466
474 ElementsKind to_kind = casted_stub()->to_kind(); 467 ElementsKind to_kind = casted_stub()->to_kind();
475 BuildNewSpaceArrayCheck(array_length, to_kind); 468 BuildNewSpaceArrayCheck(array_length, to_kind);
476 469
477 IfBuilder if_builder(this); 470 IfBuilder if_builder(this);
478 471
479 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); 472 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ);
480 if_builder.Then(); 473 if_builder.Then();
481 474
482 // Nothing to do, just change the map. 475 // Nothing to do, just change the map.
483 476
484 if_builder.Else(); 477 if_builder.Else();
485 478
486 HInstruction* elements = AddLoadElements(js_array); 479 HInstruction* elements = AddLoadElements(js_array);
487 480
488 HInstruction* elements_length = 481 HInstruction* elements_length =
489 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); 482 AddInstruction(new(zone) HFixedArrayBaseLength(elements));
490 483
491 HValue* new_elements = 484 HValue* new_elements =
492 BuildAllocateAndInitializeElements(context(), to_kind, elements_length); 485 BuildAllocateAndInitializeElements(context(), to_kind, elements_length);
493 486
494 BuildCopyElements(context(), elements, 487 BuildCopyElements(context(), elements,
495 casted_stub()->from_kind(), new_elements, 488 casted_stub()->from_kind(), new_elements,
496 to_kind, array_length, elements_length); 489 to_kind, array_length, elements_length);
497 490
498 Factory* factory = isolate()->factory(); 491 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 492
506 if_builder.End(); 493 if_builder.End();
507 494
508 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(), 495 AddStore(js_array, HObjectAccess::ForMap(), map);
509 map, true, 496
510 Representation::Tagged(),
511 JSArray::kMapOffset));
512 return js_array; 497 return js_array;
513 } 498 }
514 499
515 500
516 Handle<Code> TransitionElementsKindStub::GenerateCode() { 501 Handle<Code> TransitionElementsKindStub::GenerateCode() {
517 return DoGenerateCode(this); 502 return DoGenerateCode(this);
518 } 503 }
519 504
520 505
521 template <> 506 template <>
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 ? graph()->GetConstantSmi1() 648 ? graph()->GetConstantSmi1()
664 : graph()->GetConstantUndefined(); 649 : graph()->GetConstantUndefined();
665 } 650 }
666 651
667 652
668 Handle<Code> CompareNilICStub::GenerateCode() { 653 Handle<Code> CompareNilICStub::GenerateCode() {
669 return DoGenerateCode(this); 654 return DoGenerateCode(this);
670 } 655 }
671 656
672 } } // namespace v8::internal 657 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen.h » ('j') | src/hydrogen-instructions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698