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

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: Comment response 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
« no previous file with comments | « src/code-stubs.cc ('k') | src/factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.If<HCompareMap>(elements, factory->fixed_cow_array_map()); 333 if_fixed_cow.If<HCompareMap>(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.If<HCompareMap>(elements, factory->fixed_array_map()); 344 if_fixed.If<HCompareMap>(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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 return object; 420 return object;
416 } 421 }
417 422
418 423
419 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { 424 Handle<Code> FastCloneShallowObjectStub::GenerateCode() {
420 return DoGenerateCode(this); 425 return DoGenerateCode(this);
421 } 426 }
422 427
423 428
424 template <> 429 template <>
430 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
431 Zone* zone = this->zone();
432
433 HValue* size = AddInstruction(new(zone) HConstant(AllocationSite::kSize));
434 HAllocate::Flags flags = HAllocate::DefaultFlags();
435 flags = static_cast<HAllocate::Flags>(
436 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
437 HInstruction* object = AddInstruction(new(zone)
438 HAllocate(context(), size, HType::JSObject(), flags));
439
440 // Store the map
441 Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(),
442 isolate());
443 AddStoreMapConstant(object, allocation_site_map);
444
445 // Store the payload (smi elements kind)
446 HValue* initial_elements_kind = AddInstruction(new(zone) HConstant(
447 GetInitialFastElementsKind()));
448 AddInstruction(new(zone) HStoreNamedField(object,
449 HObjectAccess::ForAllocationSitePayload(), initial_elements_kind));
450
451 // We use a hammer (SkipWriteBarrier()) to indicate that we know the input
452 // cell is really a Cell, and so no write barrier is needed.
453 // TODO(mvstanton): Add a debug_code check to verify the input cell is really
454 // a cell. (perhaps with a new instruction, HAssert).
455 HInstruction* cell = GetParameter(0);
456 HObjectAccess access = HObjectAccess::ForCellValue();
457 HStoreNamedField* store = AddStore(cell, access, object);
458 store->SkipWriteBarrier();
459 return cell;
460 }
461
462
463 Handle<Code> CreateAllocationSiteStub::GenerateCode() {
464 return DoGenerateCode(this);
465 }
466
467
468 template <>
425 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { 469 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
426 HInstruction* load = BuildUncheckedMonomorphicElementAccess( 470 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
427 GetParameter(0), GetParameter(1), NULL, NULL, 471 GetParameter(0), GetParameter(1), NULL, NULL,
428 casted_stub()->is_js_array(), casted_stub()->elements_kind(), 472 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
429 false, NEVER_RETURN_HOLE, STANDARD_STORE); 473 false, NEVER_RETURN_HOLE, STANDARD_STORE);
430 return load; 474 return load;
431 } 475 }
432 476
433 477
434 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { 478 Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 ContextCheckMode context_mode, 585 ContextCheckMode context_mode,
542 AllocationSiteOverrideMode override_mode, 586 AllocationSiteOverrideMode override_mode,
543 ArgumentClass argument_class) { 587 ArgumentClass argument_class) {
544 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); 588 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor);
545 if (context_mode == CONTEXT_CHECK_REQUIRED) { 589 if (context_mode == CONTEXT_CHECK_REQUIRED) {
546 HInstruction* array_function = BuildGetArrayFunction(context()); 590 HInstruction* array_function = BuildGetArrayFunction(context());
547 ArrayContextChecker checker(this, constructor, array_function); 591 ArrayContextChecker checker(this, constructor, array_function);
548 } 592 }
549 593
550 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); 594 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell);
551 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,
552 override_mode); 599 override_mode);
553 HValue* result = NULL; 600 HValue* result = NULL;
554 switch (argument_class) { 601 switch (argument_class) {
555 case NONE: 602 case NONE:
556 result = array_builder.AllocateEmptyArray(); 603 result = array_builder.AllocateEmptyArray();
557 break; 604 break;
558 case SINGLE: 605 case SINGLE:
559 result = BuildArraySingleArgumentConstructor(&array_builder); 606 result = BuildArraySingleArgumentConstructor(&array_builder);
560 break; 607 break;
561 case MULTIPLE: 608 case MULTIPLE:
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 return value; 912 return value;
866 } 913 }
867 914
868 915
869 Handle<Code> StoreGlobalStub::GenerateCode() { 916 Handle<Code> StoreGlobalStub::GenerateCode() {
870 return DoGenerateCode(this); 917 return DoGenerateCode(this);
871 } 918 }
872 919
873 920
874 } } // namespace v8::internal 921 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698