| 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 bool track_allocation_site = |
| 455 (casted_stub()->allocation_site_mode() == TRACK_ALLOCATION_SITE); |
| 456 if (track_allocation_site) { |
| 457 size += AllocationMemento::kSize; |
| 458 } |
| 459 |
| 450 HValue* boilerplate_map = Add<HLoadNamedField>( | 460 HValue* boilerplate_map = Add<HLoadNamedField>( |
| 451 boilerplate, HObjectAccess::ForMap()); | 461 boilerplate, HObjectAccess::ForMap()); |
| 452 HValue* boilerplate_size = Add<HLoadNamedField>( | 462 HValue* boilerplate_size = Add<HLoadNamedField>( |
| 453 boilerplate_map, HObjectAccess::ForMapInstanceSize()); | 463 boilerplate_map, HObjectAccess::ForMapInstanceSize()); |
| 454 HValue* size_in_words = Add<HConstant>(size >> kPointerSizeLog2); | 464 HValue* size_in_words = Add<HConstant>(object_size >> kPointerSizeLog2); |
| 455 checker.If<HCompareNumericAndBranch>(boilerplate_size, | 465 checker.If<HCompareNumericAndBranch>(boilerplate_size, |
| 456 size_in_words, Token::EQ); | 466 size_in_words, Token::EQ); |
| 457 checker.Then(); | 467 checker.Then(); |
| 458 | 468 |
| 459 HValue* size_in_bytes = Add<HConstant>(size); | 469 HValue* size_in_bytes = Add<HConstant>(size); |
| 460 | 470 |
| 461 HInstruction* object = Add<HAllocate>(size_in_bytes, HType::JSObject(), | 471 HInstruction* object = Add<HAllocate>(size_in_bytes, HType::JSObject(), |
| 462 isolate()->heap()->GetPretenureMode(), JS_OBJECT_TYPE); | 472 isolate()->heap()->GetPretenureMode(), JS_OBJECT_TYPE); |
| 463 | 473 |
| 464 for (int i = 0; i < size; i += kPointerSize) { | 474 for (int i = 0; i < object_size; i += kPointerSize) { |
| 465 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i); | 475 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i); |
| 466 Add<HStoreNamedField>(object, access, | 476 Add<HStoreNamedField>(object, access, |
| 467 Add<HLoadNamedField>(boilerplate, access)); | 477 Add<HLoadNamedField>(boilerplate, access)); |
| 468 } | 478 } |
| 469 | 479 |
| 480 ASSERT(track_allocation_site || (size == object_size)); |
| 481 if (track_allocation_site) { |
| 482 BuildCreateAllocationMemento(object, object_size, allocation_site); |
| 483 } |
| 484 |
| 470 environment()->Push(object); | 485 environment()->Push(object); |
| 471 checker.ElseDeopt("Uninitialized boilerplate in fast clone"); | 486 checker.ElseDeopt("Uninitialized boilerplate in fast clone"); |
| 472 checker.End(); | 487 checker.End(); |
| 473 | 488 |
| 474 return environment()->Pop(); | 489 return environment()->Pop(); |
| 475 } | 490 } |
| 476 | 491 |
| 477 | 492 |
| 478 Handle<Code> FastCloneShallowObjectStub::GenerateCode(Isolate* isolate) { | 493 Handle<Code> FastCloneShallowObjectStub::GenerateCode(Isolate* isolate) { |
| 479 return DoGenerateCode(isolate, this); | 494 return DoGenerateCode(isolate, this); |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 return js_function; | 1248 return js_function; |
| 1234 } | 1249 } |
| 1235 | 1250 |
| 1236 | 1251 |
| 1237 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { | 1252 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { |
| 1238 return DoGenerateCode(isolate, this); | 1253 return DoGenerateCode(isolate, this); |
| 1239 } | 1254 } |
| 1240 | 1255 |
| 1241 | 1256 |
| 1242 } } // namespace v8::internal | 1257 } } // namespace v8::internal |
| OLD | NEW |