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

Side by Side Diff: src/factory.cc

Issue 2680313002: Count closures using the feedback vector cell map, specialize if count==1. (Closed)
Patch Set: Only specialize if compiling from bytecode Created 3 years, 10 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
« no previous file with comments | « src/factory.h ('k') | src/feedback-vector.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 } 1166 }
1167 1167
1168 Handle<Cell> Factory::NewCell(Handle<Object> value) { 1168 Handle<Cell> Factory::NewCell(Handle<Object> value) {
1169 AllowDeferredHandleDereference convert_to_cell; 1169 AllowDeferredHandleDereference convert_to_cell;
1170 CALL_HEAP_FUNCTION( 1170 CALL_HEAP_FUNCTION(
1171 isolate(), 1171 isolate(),
1172 isolate()->heap()->AllocateCell(*value), 1172 isolate()->heap()->AllocateCell(*value),
1173 Cell); 1173 Cell);
1174 } 1174 }
1175 1175
1176 Handle<Cell> Factory::NewNoClosuresCell(Handle<Object> value) {
1177 Handle<Cell> cell = NewCell(value);
1178 cell->set_map_no_write_barrier(*no_closures_cell_map());
1179 return cell;
1180 }
1181
1182 Handle<Cell> Factory::NewOneClosureCell(Handle<Object> value) {
1183 Handle<Cell> cell = NewCell(value);
1184 cell->set_map_no_write_barrier(*one_closure_cell_map());
1185 return cell;
1186 }
1187
1188 Handle<Cell> Factory::NewManyClosuresCell(Handle<Object> value) {
1189 Handle<Cell> cell = NewCell(value);
1190 cell->set_map_no_write_barrier(*many_closures_cell_map());
1191 return cell;
1192 }
1193
1176 Handle<PropertyCell> Factory::NewPropertyCell() { 1194 Handle<PropertyCell> Factory::NewPropertyCell() {
1177 CALL_HEAP_FUNCTION( 1195 CALL_HEAP_FUNCTION(
1178 isolate(), 1196 isolate(),
1179 isolate()->heap()->AllocatePropertyCell(), 1197 isolate()->heap()->AllocatePropertyCell(),
1180 PropertyCell); 1198 PropertyCell);
1181 } 1199 }
1182 1200
1183 1201
1184 Handle<WeakCell> Factory::NewWeakCell(Handle<HeapObject> value) { 1202 Handle<WeakCell> Factory::NewWeakCell(Handle<HeapObject> value) {
1185 // It is safe to dereference the value because we are embedding it 1203 // It is safe to dereference the value because we are embedding it
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 } 1601 }
1584 1602
1585 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 1603 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1586 Handle<Map> initial_map, Handle<SharedFunctionInfo> info, 1604 Handle<Map> initial_map, Handle<SharedFunctionInfo> info,
1587 Handle<Object> context_or_undefined, Handle<Cell> vector, 1605 Handle<Object> context_or_undefined, Handle<Cell> vector,
1588 PretenureFlag pretenure) { 1606 PretenureFlag pretenure) {
1589 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); 1607 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type());
1590 Handle<JSFunction> result = 1608 Handle<JSFunction> result =
1591 NewFunction(initial_map, info, context_or_undefined, pretenure); 1609 NewFunction(initial_map, info, context_or_undefined, pretenure);
1592 1610
1611 // Bump the closure count that is encoded in the vector cell's map.
1612 if (vector->map() == *no_closures_cell_map()) {
1613 vector->set_map(*one_closure_cell_map());
1614 } else if (vector->map() == *one_closure_cell_map()) {
1615 vector->set_map(*many_closures_cell_map());
1616 } else {
1617 DCHECK_EQ(vector->map(), *many_closures_cell_map());
1618 }
1619
1593 result->set_feedback_vector_cell(*vector); 1620 result->set_feedback_vector_cell(*vector);
1594 if (info->ic_age() != isolate()->heap()->global_ic_age()) { 1621 if (info->ic_age() != isolate()->heap()->global_ic_age()) {
1595 info->ResetForNewContext(isolate()->heap()->global_ic_age()); 1622 info->ResetForNewContext(isolate()->heap()->global_ic_age());
1596 } 1623 }
1597 1624
1598 if (context_or_undefined->IsContext()) { 1625 if (context_or_undefined->IsContext()) {
1599 // Give compiler a chance to pre-initialize. 1626 // Give compiler a chance to pre-initialize.
1600 Compiler::PostInstantiation(result, pretenure); 1627 Compiler::PostInstantiation(result, pretenure);
1601 } 1628 }
1602 1629
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 Handle<AccessorInfo> prototype = 2875 Handle<AccessorInfo> prototype =
2849 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); 2876 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs);
2850 Descriptor d = Descriptor::AccessorConstant( 2877 Descriptor d = Descriptor::AccessorConstant(
2851 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); 2878 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs);
2852 map->AppendDescriptor(&d); 2879 map->AppendDescriptor(&d);
2853 } 2880 }
2854 } 2881 }
2855 2882
2856 } // namespace internal 2883 } // namespace internal
2857 } // namespace v8 2884 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/feedback-vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698