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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 15094018: Create AllocationSite objects, pointed to by AllocationSiteInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code comments, round 2 (thx!) Created 7 years, 5 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 HAllocate::Flags flags = HAllocate::DefaultFlags();
434 flags = static_cast<HAllocate::Flags>(
435 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
436 HInstruction* object = AddInstruction(new(zone)
437 HAllocate(context(), size, HType::JSObject(), flags));
438
439 // Store the map
440 Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(),
441 isolate());
442 AddStoreMapConstant(object, allocation_site_map);
443
444 // Store the payload (smi elements kind)
445 HValue* initial_elements_kind = AddInstruction(new(zone) HConstant(
446 GetInitialFastElementsKind()));
447 AddInstruction(new(zone) HStoreNamedField(object,
448 HObjectAccess::ForAllocationSitePayload(), initial_elements_kind));
449
450 // We use a hammer (SkipWriteBarrier()) to indicate that we know the input
451 // cell is really a Cell, and so no write barrier is needed.
452 // TODO(mvstanton): Add a debug_code check to verify the input cell is really
453 // a cell. (perhaps with a new instruction, HAssert).
454 HInstruction* cell = GetParameter(0);
455 HObjectAccess access = HObjectAccess::ForCellValue();
456 HStoreNamedField* store = AddStore(cell, access, object);
457 store->SkipWriteBarrier();
458 return cell;
459 }
460
461
462 Handle<Code> CreateAllocationSiteStub::GenerateCode() {
463 return DoGenerateCode(this);
464 }
465
466
467 template <>
424 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { 468 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
425 HInstruction* load = BuildUncheckedMonomorphicElementAccess( 469 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
426 GetParameter(0), GetParameter(1), NULL, NULL, 470 GetParameter(0), GetParameter(1), NULL, NULL,
427 casted_stub()->is_js_array(), casted_stub()->elements_kind(), 471 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
428 false, NEVER_RETURN_HOLE, STANDARD_STORE); 472 false, NEVER_RETURN_HOLE, STANDARD_STORE);
429 return load; 473 return load;
430 } 474 }
431 475
432 476
433 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { 477 Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 ContextCheckMode context_mode, 583 ContextCheckMode context_mode,
540 AllocationSiteOverrideMode override_mode, 584 AllocationSiteOverrideMode override_mode,
541 ArgumentClass argument_class) { 585 ArgumentClass argument_class) {
542 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); 586 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor);
543 if (context_mode == CONTEXT_CHECK_REQUIRED) { 587 if (context_mode == CONTEXT_CHECK_REQUIRED) {
544 HInstruction* array_function = BuildGetArrayFunction(context()); 588 HInstruction* array_function = BuildGetArrayFunction(context());
545 ArrayContextChecker checker(this, constructor, array_function); 589 ArrayContextChecker checker(this, constructor, array_function);
546 } 590 }
547 591
548 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); 592 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell);
549 JSArrayBuilder array_builder(this, kind, property_cell, constructor, 593 // Walk through the property cell to the AllocationSite
594 HValue* alloc_site = AddInstruction(new(zone()) HLoadNamedField(property_cell,
595 HObjectAccess::ForCellValue()));
596 JSArrayBuilder array_builder(this, kind, alloc_site, constructor,
550 override_mode); 597 override_mode);
551 HValue* result = NULL; 598 HValue* result = NULL;
552 switch (argument_class) { 599 switch (argument_class) {
553 case NONE: 600 case NONE:
554 result = array_builder.AllocateEmptyArray(); 601 result = array_builder.AllocateEmptyArray();
555 break; 602 break;
556 case SINGLE: 603 case SINGLE:
557 result = BuildArraySingleArgumentConstructor(&array_builder); 604 result = BuildArraySingleArgumentConstructor(&array_builder);
558 break; 605 break;
559 case MULTIPLE: 606 case MULTIPLE:
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 return graph()->GetConstant0(); 824 return graph()->GetConstant0();
778 } 825 }
779 826
780 827
781 Handle<Code> ToBooleanStub::GenerateCode() { 828 Handle<Code> ToBooleanStub::GenerateCode() {
782 return DoGenerateCode(this); 829 return DoGenerateCode(this);
783 } 830 }
784 831
785 832
786 } } // namespace v8::internal 833 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698