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

Side by Side Diff: src/runtime.cc

Issue 26539010: Revert "AllocationSites for all literals" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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/objects.cc ('k') | test/mjsunit/allocation-site-info.js » ('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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <limits> 29 #include <limits>
30 30
31 #include "v8.h" 31 #include "v8.h"
32 32
33 #include "accessors.h" 33 #include "accessors.h"
34 #include "allocation-site-scopes.h"
35 #include "api.h" 34 #include "api.h"
36 #include "arguments.h" 35 #include "arguments.h"
37 #include "bootstrapper.h" 36 #include "bootstrapper.h"
38 #include "codegen.h" 37 #include "codegen.h"
39 #include "compilation-cache.h" 38 #include "compilation-cache.h"
40 #include "compiler.h" 39 #include "compiler.h"
41 #include "cpu.h" 40 #include "cpu.h"
42 #include "cpu-profiler.h" 41 #include "cpu-profiler.h"
43 #include "dateparser-inl.h" 42 #include "dateparser-inl.h"
44 #include "debug.h" 43 #include "debug.h"
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 481 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
483 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 482 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
484 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); 483 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
485 CONVERT_SMI_ARG_CHECKED(flags, 3); 484 CONVERT_SMI_ARG_CHECKED(flags, 3);
486 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 485 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
487 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 486 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
488 487
489 // Check if boilerplate exists. If not, create it first. 488 // Check if boilerplate exists. If not, create it first.
490 Handle<Object> literal_site(literals->get(literals_index), isolate); 489 Handle<Object> literal_site(literals->get(literals_index), isolate);
491 Handle<AllocationSite> site; 490 Handle<AllocationSite> site;
492 Handle<JSObject> boilerplate; 491 Handle<Object> boilerplate;
493 if (*literal_site == isolate->heap()->undefined_value()) { 492 if (*literal_site == isolate->heap()->undefined_value()) {
494 Handle<Object> raw_boilerplate = CreateObjectLiteralBoilerplate( 493 boilerplate = CreateObjectLiteralBoilerplate(isolate,
495 isolate, 494 literals,
496 literals, 495 constant_properties,
497 constant_properties, 496 should_have_fast_elements,
498 should_have_fast_elements, 497 has_function_literal);
499 has_function_literal); 498 RETURN_IF_EMPTY_HANDLE(isolate, boilerplate);
500 RETURN_IF_EMPTY_HANDLE(isolate, raw_boilerplate); 499 site = isolate->factory()->NewAllocationSite();
501 boilerplate = Handle<JSObject>::cast(raw_boilerplate); 500 site->set_transition_info(*boilerplate);
502
503 AllocationSiteCreationContext creation_context(isolate);
504 site = creation_context.EnterNewScope();
505 JSObject::DeepWalk(boilerplate, &creation_context);
506 creation_context.ExitScope(site, boilerplate);
507 501
508 // Update the functions literal and return the boilerplate. 502 // Update the functions literal and return the boilerplate.
509 literals->set(literals_index, *site); 503 literals->set(literals_index, *site);
510 } else { 504 } else {
511 site = Handle<AllocationSite>::cast(literal_site); 505 site = Handle<AllocationSite>::cast(literal_site);
512 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), 506 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()));
513 isolate);
514 } 507 }
515 508
516 AllocationSiteUsageContext usage_context(isolate, site, true); 509 Handle<Object> copy = JSObject::DeepCopy(Handle<JSObject>::cast(boilerplate));
517 usage_context.EnterNewScope();
518 Handle<Object> copy = JSObject::DeepCopy(boilerplate, &usage_context);
519 usage_context.ExitScope(site, boilerplate);
520 RETURN_IF_EMPTY_HANDLE(isolate, copy); 510 RETURN_IF_EMPTY_HANDLE(isolate, copy);
521 return *copy; 511 return *copy;
522 } 512 }
523 513
524 514
525 static Handle<AllocationSite> GetLiteralAllocationSite( 515 static Handle<AllocationSite> GetLiteralAllocationSite(
526 Isolate* isolate, 516 Isolate* isolate,
527 Handle<FixedArray> literals, 517 Handle<FixedArray> literals,
528 int literals_index, 518 int literals_index,
529 Handle<FixedArray> elements) { 519 Handle<FixedArray> elements) {
530 // Check if boilerplate exists. If not, create it first. 520 // Check if boilerplate exists. If not, create it first.
531 Handle<Object> literal_site(literals->get(literals_index), isolate); 521 Handle<Object> literal_site(literals->get(literals_index), isolate);
532 Handle<AllocationSite> site; 522 Handle<AllocationSite> site;
533 if (*literal_site == isolate->heap()->undefined_value()) { 523 if (*literal_site == isolate->heap()->undefined_value()) {
534 ASSERT(*elements != isolate->heap()->empty_fixed_array()); 524 ASSERT(*elements != isolate->heap()->empty_fixed_array());
535 Handle<Object> boilerplate = 525 Handle<Object> boilerplate =
536 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); 526 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements);
537 if (boilerplate.is_null()) return Handle<AllocationSite>::null(); 527 if (boilerplate.is_null()) {
538 528 ASSERT(site.is_null());
539 AllocationSiteCreationContext creation_context(isolate); 529 return site;
540 site = creation_context.EnterNewScope(); 530 }
541 JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate), &creation_context); 531 site = isolate->factory()->NewAllocationSite();
542 creation_context.ExitScope(site, Handle<JSObject>::cast(boilerplate)); 532 site->set_transition_info(*boilerplate);
543
544 literals->set(literals_index, *site); 533 literals->set(literals_index, *site);
545 } else { 534 } else {
546 site = Handle<AllocationSite>::cast(literal_site); 535 site = Handle<AllocationSite>::cast(literal_site);
547 } 536 }
548 537
549 return site; 538 return site;
550 } 539 }
551 540
552 541
553 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { 542 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
554 HandleScope scope(isolate); 543 HandleScope scope(isolate);
555 ASSERT(args.length() == 3); 544 ASSERT(args.length() == 3);
556 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 545 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
557 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 546 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
558 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 547 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
559 548
560 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, 549 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
561 literals_index, elements); 550 literals_index, elements);
562 RETURN_IF_EMPTY_HANDLE(isolate, site); 551 RETURN_IF_EMPTY_HANDLE(isolate, site);
563 552
564 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); 553 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()));
565 AllocationSiteUsageContext usage_context(isolate, site, true); 554 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate);
566 usage_context.EnterNewScope();
567 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context);
568 usage_context.ExitScope(site, boilerplate);
569 RETURN_IF_EMPTY_HANDLE(isolate, copy); 555 RETURN_IF_EMPTY_HANDLE(isolate, copy);
570 return *copy; 556 return *copy;
571 } 557 }
572 558
573 559
574 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { 560 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
575 HandleScope scope(isolate); 561 HandleScope scope(isolate);
576 ASSERT(args.length() == 3); 562 ASSERT(args.length() == 3);
577 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 563 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
578 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 564 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
579 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 565 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
580 566
581 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, 567 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
582 literals_index, elements); 568 literals_index, elements);
583 RETURN_IF_EMPTY_HANDLE(isolate, site); 569 RETURN_IF_EMPTY_HANDLE(isolate, site);
584 570
585 JSObject* boilerplate = JSObject::cast(site->transition_info()); 571 JSObject* boilerplate = JSObject::cast(site->transition_info());
586 if (boilerplate->elements()->map() == 572 if (boilerplate->elements()->map() ==
587 isolate->heap()->fixed_cow_array_map()) { 573 isolate->heap()->fixed_cow_array_map()) {
588 isolate->counters()->cow_arrays_created_runtime()->Increment(); 574 isolate->counters()->cow_arrays_created_runtime()->Increment();
589 } 575 }
590 576
591 if (AllocationSite::GetMode(boilerplate->GetElementsKind()) == 577 AllocationSiteMode mode = AllocationSite::GetMode(
592 TRACK_ALLOCATION_SITE) { 578 boilerplate->GetElementsKind());
579 if (mode == TRACK_ALLOCATION_SITE) {
593 return isolate->heap()->CopyJSObject(boilerplate, *site); 580 return isolate->heap()->CopyJSObject(boilerplate, *site);
594 } 581 }
595 582
596 return isolate->heap()->CopyJSObject(boilerplate); 583 return isolate->heap()->CopyJSObject(boilerplate);
597 } 584 }
598 585
599 586
600 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { 587 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) {
601 HandleScope scope(isolate); 588 HandleScope scope(isolate);
602 ASSERT(args.length() == 1); 589 ASSERT(args.length() == 1);
(...skipping 14088 matching lines...) Expand 10 before | Expand all | Expand 10 after
14691 14678
14692 JSArray* array; 14679 JSArray* array;
14693 MaybeObject* maybe_array; 14680 MaybeObject* maybe_array;
14694 if (!type_info.is_null() && 14681 if (!type_info.is_null() &&
14695 *type_info != isolate->heap()->undefined_value() && 14682 *type_info != isolate->heap()->undefined_value() &&
14696 Cell::cast(*type_info)->value()->IsAllocationSite() && 14683 Cell::cast(*type_info)->value()->IsAllocationSite() &&
14697 can_use_type_feedback) { 14684 can_use_type_feedback) {
14698 Handle<Cell> cell = Handle<Cell>::cast(type_info); 14685 Handle<Cell> cell = Handle<Cell>::cast(type_info);
14699 Handle<AllocationSite> site = Handle<AllocationSite>( 14686 Handle<AllocationSite> site = Handle<AllocationSite>(
14700 AllocationSite::cast(cell->value()), isolate); 14687 AllocationSite::cast(cell->value()), isolate);
14701 ASSERT(!site->SitePointsToLiteral()); 14688 ASSERT(!site->IsLiteralSite());
14702 ElementsKind to_kind = site->GetElementsKind(); 14689 ElementsKind to_kind = site->GetElementsKind();
14703 if (holey && !IsFastHoleyElementsKind(to_kind)) { 14690 if (holey && !IsFastHoleyElementsKind(to_kind)) {
14704 to_kind = GetHoleyElementsKind(to_kind); 14691 to_kind = GetHoleyElementsKind(to_kind);
14705 // Update the allocation site info to reflect the advice alteration. 14692 // Update the allocation site info to reflect the advice alteration.
14706 site->SetElementsKind(to_kind); 14693 site->SetElementsKind(to_kind);
14707 } 14694 }
14708 14695
14709 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( 14696 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite(
14710 *constructor, site); 14697 *constructor, site);
14711 if (!maybe_array->To(&array)) return maybe_array; 14698 if (!maybe_array->To(&array)) return maybe_array;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
14847 // Handle last resort GC and make sure to allow future allocations 14834 // Handle last resort GC and make sure to allow future allocations
14848 // to grow the heap without causing GCs (if possible). 14835 // to grow the heap without causing GCs (if possible).
14849 isolate->counters()->gc_last_resort_from_js()->Increment(); 14836 isolate->counters()->gc_last_resort_from_js()->Increment();
14850 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14837 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14851 "Runtime::PerformGC"); 14838 "Runtime::PerformGC");
14852 } 14839 }
14853 } 14840 }
14854 14841
14855 14842
14856 } } // namespace v8::internal 14843 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/allocation-site-info.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698