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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 | 308 |
309 template <> | 309 template <> |
310 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { | 310 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
311 Zone* zone = this->zone(); | 311 Zone* zone = this->zone(); |
312 Factory* factory = isolate()->factory(); | 312 Factory* factory = isolate()->factory(); |
313 HValue* undefined = graph()->GetConstantUndefined(); | 313 HValue* undefined = graph()->GetConstantUndefined(); |
314 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); | 314 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); |
315 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); | 315 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); |
316 int length = casted_stub()->length(); | 316 int length = casted_stub()->length(); |
317 | 317 |
318 HInstruction* boilerplate = | 318 HInstruction* allocation_site = |
319 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), | 319 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
320 GetParameter(1), | 320 GetParameter(1), |
321 NULL, | 321 NULL, |
322 FAST_ELEMENTS)); | 322 FAST_ELEMENTS)); |
323 | |
324 IfBuilder checker(this); | 323 IfBuilder checker(this); |
325 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); | 324 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, undefined); |
326 checker.Then(); | 325 checker.Then(); |
327 | 326 |
327 HObjectAccess access = HObjectAccess::ForAllocationSiteInfoSite(); | |
328 HInstruction* boilerplate = AddLoad(allocation_site, access); | |
328 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { | 329 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { |
329 HValue* elements = AddLoadElements(boilerplate); | 330 HValue* elements = AddLoadElements(boilerplate); |
330 | 331 |
331 IfBuilder if_fixed_cow(this); | 332 IfBuilder if_fixed_cow(this); |
332 if_fixed_cow.IfCompareMap(elements, factory->fixed_cow_array_map()); | 333 if_fixed_cow.IfCompareMap(elements, factory->fixed_cow_array_map()); |
333 if_fixed_cow.Then(); | 334 if_fixed_cow.Then(); |
334 environment()->Push(BuildCloneShallowArray(context(), | 335 environment()->Push(BuildCloneShallowArray(context(), |
335 boilerplate, | 336 boilerplate, |
337 allocation_site, | |
336 alloc_site_mode, | 338 alloc_site_mode, |
337 FAST_ELEMENTS, | 339 FAST_ELEMENTS, |
338 0/*copy-on-write*/)); | 340 0/*copy-on-write*/)); |
339 if_fixed_cow.Else(); | 341 if_fixed_cow.Else(); |
340 | 342 |
341 IfBuilder if_fixed(this); | 343 IfBuilder if_fixed(this); |
342 if_fixed.IfCompareMap(elements, factory->fixed_array_map()); | 344 if_fixed.IfCompareMap(elements, factory->fixed_array_map()); |
343 if_fixed.Then(); | 345 if_fixed.Then(); |
344 environment()->Push(BuildCloneShallowArray(context(), | 346 environment()->Push(BuildCloneShallowArray(context(), |
345 boilerplate, | 347 boilerplate, |
348 allocation_site, | |
346 alloc_site_mode, | 349 alloc_site_mode, |
347 FAST_ELEMENTS, | 350 FAST_ELEMENTS, |
348 length)); | 351 length)); |
349 if_fixed.Else(); | 352 if_fixed.Else(); |
350 environment()->Push(BuildCloneShallowArray(context(), | 353 environment()->Push(BuildCloneShallowArray(context(), |
351 boilerplate, | 354 boilerplate, |
355 allocation_site, | |
352 alloc_site_mode, | 356 alloc_site_mode, |
353 FAST_DOUBLE_ELEMENTS, | 357 FAST_DOUBLE_ELEMENTS, |
354 length)); | 358 length)); |
355 } else { | 359 } else { |
356 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); | 360 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); |
357 environment()->Push(BuildCloneShallowArray(context(), | 361 environment()->Push(BuildCloneShallowArray(context(), |
358 boilerplate, | 362 boilerplate, |
363 allocation_site, | |
359 alloc_site_mode, | 364 alloc_site_mode, |
360 elements_kind, | 365 elements_kind, |
361 length)); | 366 length)); |
362 } | 367 } |
363 | 368 |
364 HValue* result = environment()->Pop(); | 369 HValue* result = environment()->Pop(); |
365 checker.ElseDeopt(); | 370 checker.ElseDeopt(); |
366 return result; | 371 return result; |
367 } | 372 } |
368 | 373 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 return object; | 419 return object; |
415 } | 420 } |
416 | 421 |
417 | 422 |
418 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { | 423 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { |
419 return DoGenerateCode(this); | 424 return DoGenerateCode(this); |
420 } | 425 } |
421 | 426 |
422 | 427 |
423 template <> | 428 template <> |
429 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() { | |
430 Zone* zone = this->zone(); | |
431 | |
432 HValue* size = AddInstruction(new(zone) HConstant(AllocationSite::kSize)); | |
433 // TODO(mvstanton): perhaps flags should be old space allocation | |
434 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; | |
Hannes Payer (out of office)
2013/07/03 15:26:45
We could do that right away.
mvstanton
2013/07/05 07:56:14
Done.
| |
435 HInstruction* object = AddInstruction(new(zone) | |
436 HAllocate(context(), size, HType::JSObject(), flags)); | |
437 // Store the map | |
438 Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(), | |
439 isolate()); | |
440 AddStoreMapConstant(object, allocation_site_map); | |
441 HValue* initial_elements_kind = AddInstruction(new(zone) HConstant( | |
442 GetInitialFastElementsKind())); | |
443 AddInstruction(new(zone) HStoreNamedField(object, | |
444 HObjectAccess::ForAllocationSitePayload(), initial_elements_kind)); | |
445 | |
446 // We use a hammer (SkipWriteBarrier()) to indicate that we know the input | |
447 // cell is really a Cell, and so no write barrier is needed. Protect with a | |
448 // debug code check. | |
449 HInstruction* cell = GetParameter(0); | |
450 // TODO(mvstanton): make debug code - new instruction, HAssert? | |
451 /* | |
Hannes Payer (out of office)
2013/07/03 15:26:45
This seems to be not finished.
mvstanton
2013/07/05 07:56:14
I kept the TODO, and altered it to say come back i
| |
452 if (FLAG_debug_code) { | |
453 | |
454 } | |
455 */ | |
456 | |
457 HObjectAccess access = HObjectAccess::ForCellValue(); | |
458 HStoreNamedField* store = AddStore(cell, access, object); | |
459 store->SkipWriteBarrier(); | |
460 return cell; | |
461 } | |
462 | |
463 | |
464 Handle<Code> CreateAllocationSiteStub::GenerateCode() { | |
465 return DoGenerateCode(this); | |
466 } | |
467 | |
468 | |
469 template <> | |
424 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { | 470 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { |
425 HInstruction* load = BuildUncheckedMonomorphicElementAccess( | 471 HInstruction* load = BuildUncheckedMonomorphicElementAccess( |
426 GetParameter(0), GetParameter(1), NULL, NULL, | 472 GetParameter(0), GetParameter(1), NULL, NULL, |
427 casted_stub()->is_js_array(), casted_stub()->elements_kind(), | 473 casted_stub()->is_js_array(), casted_stub()->elements_kind(), |
428 false, NEVER_RETURN_HOLE, STANDARD_STORE); | 474 false, NEVER_RETURN_HOLE, STANDARD_STORE); |
429 return load; | 475 return load; |
430 } | 476 } |
431 | 477 |
432 | 478 |
433 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { | 479 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 ContextCheckMode context_mode, | 585 ContextCheckMode context_mode, |
540 AllocationSiteOverrideMode override_mode, | 586 AllocationSiteOverrideMode override_mode, |
541 ArgumentClass argument_class) { | 587 ArgumentClass argument_class) { |
542 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); | 588 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); |
543 if (context_mode == CONTEXT_CHECK_REQUIRED) { | 589 if (context_mode == CONTEXT_CHECK_REQUIRED) { |
544 HInstruction* array_function = BuildGetArrayFunction(context()); | 590 HInstruction* array_function = BuildGetArrayFunction(context()); |
545 ArrayContextChecker checker(this, constructor, array_function); | 591 ArrayContextChecker checker(this, constructor, array_function); |
546 } | 592 } |
547 | 593 |
548 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); | 594 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); |
549 JSArrayBuilder array_builder(this, kind, property_cell, constructor, | 595 // Walk through the property cell to the AllocationSite |
596 HValue* alloc_site = AddInstruction(new(zone()) HLoadNamedField(property_cell, | |
597 HObjectAccess::ForCellValue())); | |
598 JSArrayBuilder array_builder(this, kind, alloc_site, constructor, | |
550 override_mode); | 599 override_mode); |
551 HValue* result = NULL; | 600 HValue* result = NULL; |
552 switch (argument_class) { | 601 switch (argument_class) { |
553 case NONE: | 602 case NONE: |
554 result = array_builder.AllocateEmptyArray(); | 603 result = array_builder.AllocateEmptyArray(); |
555 break; | 604 break; |
556 case SINGLE: | 605 case SINGLE: |
557 result = BuildArraySingleArgumentConstructor(&array_builder); | 606 result = BuildArraySingleArgumentConstructor(&array_builder); |
558 break; | 607 break; |
559 case MULTIPLE: | 608 case MULTIPLE: |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
777 return graph()->GetConstant0(); | 826 return graph()->GetConstant0(); |
778 } | 827 } |
779 | 828 |
780 | 829 |
781 Handle<Code> ToBooleanStub::GenerateCode() { | 830 Handle<Code> ToBooleanStub::GenerateCode() { |
782 return DoGenerateCode(this); | 831 return DoGenerateCode(this); |
783 } | 832 } |
784 | 833 |
785 | 834 |
786 } } // namespace v8::internal | 835 } } // namespace v8::internal |
OLD | NEW |