OLD | NEW |
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 Handle<Code> FastCloneShallowArrayStub::GenerateCode(Isolate* isolate) { | 430 Handle<Code> FastCloneShallowArrayStub::GenerateCode(Isolate* isolate) { |
431 return DoGenerateCode(isolate, this); | 431 return DoGenerateCode(isolate, this); |
432 } | 432 } |
433 | 433 |
434 | 434 |
435 template <> | 435 template <> |
436 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { | 436 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { |
437 HValue* undefined = graph()->GetConstantUndefined(); | 437 HValue* undefined = graph()->GetConstantUndefined(); |
438 | 438 |
439 HInstruction* boilerplate = Add<HLoadKeyed>(GetParameter(0), | 439 HInstruction* allocation_site = Add<HLoadKeyed>(GetParameter(0), |
440 GetParameter(1), | 440 GetParameter(1), |
441 static_cast<HValue*>(NULL), | 441 static_cast<HValue*>(NULL), |
442 FAST_ELEMENTS); | 442 FAST_ELEMENTS); |
443 | 443 |
444 IfBuilder checker(this); | 444 IfBuilder checker(this); |
445 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, | 445 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, |
446 undefined); | 446 undefined); |
447 checker.And(); | 447 checker.And(); |
448 | 448 |
| 449 HObjectAccess access = HObjectAccess::ForAllocationSiteTransitionInfo(); |
| 450 HInstruction* boilerplate = Add<HLoadNamedField>(allocation_site, access); |
| 451 |
449 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; | 452 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; |
| 453 int object_size = size; |
| 454 if (FLAG_allocation_site_pretenuring) { |
| 455 size += AllocationMemento::kSize; |
| 456 } |
| 457 |
450 HValue* boilerplate_map = Add<HLoadNamedField>( | 458 HValue* boilerplate_map = Add<HLoadNamedField>( |
451 boilerplate, HObjectAccess::ForMap()); | 459 boilerplate, HObjectAccess::ForMap()); |
452 HValue* boilerplate_size = Add<HLoadNamedField>( | 460 HValue* boilerplate_size = Add<HLoadNamedField>( |
453 boilerplate_map, HObjectAccess::ForMapInstanceSize()); | 461 boilerplate_map, HObjectAccess::ForMapInstanceSize()); |
454 HValue* size_in_words = Add<HConstant>(size >> kPointerSizeLog2); | 462 HValue* size_in_words = Add<HConstant>(object_size >> kPointerSizeLog2); |
455 checker.If<HCompareNumericAndBranch>(boilerplate_size, | 463 checker.If<HCompareNumericAndBranch>(boilerplate_size, |
456 size_in_words, Token::EQ); | 464 size_in_words, Token::EQ); |
457 checker.Then(); | 465 checker.Then(); |
458 | 466 |
459 HValue* size_in_bytes = Add<HConstant>(size); | 467 HValue* size_in_bytes = Add<HConstant>(size); |
460 | 468 |
461 HInstruction* object = Add<HAllocate>(size_in_bytes, HType::JSObject(), | 469 HInstruction* object = Add<HAllocate>(size_in_bytes, HType::JSObject(), |
462 isolate()->heap()->GetPretenureMode(), JS_OBJECT_TYPE); | 470 isolate()->heap()->GetPretenureMode(), JS_OBJECT_TYPE); |
463 | 471 |
464 for (int i = 0; i < size; i += kPointerSize) { | 472 for (int i = 0; i < object_size; i += kPointerSize) { |
465 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i); | 473 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i); |
466 Add<HStoreNamedField>(object, access, | 474 Add<HStoreNamedField>(object, access, |
467 Add<HLoadNamedField>(boilerplate, access)); | 475 Add<HLoadNamedField>(boilerplate, access)); |
468 } | 476 } |
469 | 477 |
| 478 ASSERT(FLAG_allocation_site_pretenuring || (size == object_size)); |
| 479 if (FLAG_allocation_site_pretenuring) { |
| 480 BuildCreateAllocationMemento(object, object_size, allocation_site); |
| 481 } |
| 482 |
470 environment()->Push(object); | 483 environment()->Push(object); |
471 checker.ElseDeopt("Uninitialized boilerplate in fast clone"); | 484 checker.ElseDeopt("Uninitialized boilerplate in fast clone"); |
472 checker.End(); | 485 checker.End(); |
473 | 486 |
474 return environment()->Pop(); | 487 return environment()->Pop(); |
475 } | 488 } |
476 | 489 |
477 | 490 |
478 Handle<Code> FastCloneShallowObjectStub::GenerateCode(Isolate* isolate) { | 491 Handle<Code> FastCloneShallowObjectStub::GenerateCode(Isolate* isolate) { |
479 return DoGenerateCode(isolate, this); | 492 return DoGenerateCode(isolate, this); |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 return js_function; | 1246 return js_function; |
1234 } | 1247 } |
1235 | 1248 |
1236 | 1249 |
1237 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { | 1250 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { |
1238 return DoGenerateCode(isolate, this); | 1251 return DoGenerateCode(isolate, this); |
1239 } | 1252 } |
1240 | 1253 |
1241 | 1254 |
1242 } } // namespace v8::internal | 1255 } } // namespace v8::internal |
OLD | NEW |