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

Side by Side Diff: src/factory.cc

Issue 2674593003: [TypeFeedbackVector] Root feedback vectors at function literal site. (Closed)
Patch Set: REBASE. 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
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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 Handle<JSFunction> function = New<JSFunction>(map, space); 1414 Handle<JSFunction> function = New<JSFunction>(map, space);
1415 DCHECK(context_or_undefined->IsContext() || 1415 DCHECK(context_or_undefined->IsContext() ||
1416 context_or_undefined->IsUndefined(isolate())); 1416 context_or_undefined->IsUndefined(isolate()));
1417 1417
1418 function->initialize_properties(); 1418 function->initialize_properties();
1419 function->initialize_elements(); 1419 function->initialize_elements();
1420 function->set_shared(*info); 1420 function->set_shared(*info);
1421 function->set_code(info->code()); 1421 function->set_code(info->code());
1422 function->set_context(*context_or_undefined); 1422 function->set_context(*context_or_undefined);
1423 function->set_prototype_or_initial_map(*the_hole_value()); 1423 function->set_prototype_or_initial_map(*the_hole_value());
1424 function->set_feedback_vector( 1424 function->set_feedback_vector_cell(*undefined_cell());
1425 TypeFeedbackVector::cast(*empty_type_feedback_vector()));
1426 function->set_next_function_link(*undefined_value(), SKIP_WRITE_BARRIER); 1425 function->set_next_function_link(*undefined_value(), SKIP_WRITE_BARRIER);
1427 isolate()->heap()->InitializeJSObjectBody(*function, *map, JSFunction::kSize); 1426 isolate()->heap()->InitializeJSObjectBody(*function, *map, JSFunction::kSize);
1428 return function; 1427 return function;
1429 } 1428 }
1430 1429
1431 1430
1432 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, 1431 Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
1433 Handle<String> name, 1432 Handle<String> name,
1434 MaybeHandle<Code> code) { 1433 MaybeHandle<Code> code) {
1435 Handle<Context> context(isolate()->native_context()); 1434 Handle<Context> context(isolate()->native_context());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 int map_index = 1547 int map_index =
1549 Context::FunctionMapIndex(info->language_mode(), info->kind()); 1548 Context::FunctionMapIndex(info->language_mode(), info->kind());
1550 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index))); 1549 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index)));
1551 1550
1552 return NewFunctionFromSharedFunctionInfo(initial_map, info, context, 1551 return NewFunctionFromSharedFunctionInfo(initial_map, info, context,
1553 pretenure); 1552 pretenure);
1554 } 1553 }
1555 1554
1556 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 1555 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1557 Handle<SharedFunctionInfo> info, Handle<Context> context, 1556 Handle<SharedFunctionInfo> info, Handle<Context> context,
1558 Handle<TypeFeedbackVector> vector, PretenureFlag pretenure) { 1557 Handle<Cell> vector, PretenureFlag pretenure) {
1559 int map_index = 1558 int map_index =
1560 Context::FunctionMapIndex(info->language_mode(), info->kind()); 1559 Context::FunctionMapIndex(info->language_mode(), info->kind());
1561 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index))); 1560 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index)));
1562 1561
1563 return NewFunctionFromSharedFunctionInfo(initial_map, info, context, vector, 1562 return NewFunctionFromSharedFunctionInfo(initial_map, info, context, vector,
1564 pretenure); 1563 pretenure);
1565 } 1564 }
1566 1565
1567 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 1566 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1568 Handle<Map> initial_map, Handle<SharedFunctionInfo> info, 1567 Handle<Map> initial_map, Handle<SharedFunctionInfo> info,
1569 Handle<Object> context_or_undefined, PretenureFlag pretenure) { 1568 Handle<Object> context_or_undefined, PretenureFlag pretenure) {
1570 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); 1569 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type());
1571 Handle<JSFunction> result = 1570 Handle<JSFunction> result =
1572 NewFunction(initial_map, info, context_or_undefined, pretenure); 1571 NewFunction(initial_map, info, context_or_undefined, pretenure);
1573 1572
1574 if (info->ic_age() != isolate()->heap()->global_ic_age()) { 1573 if (info->ic_age() != isolate()->heap()->global_ic_age()) {
1575 info->ResetForNewContext(isolate()->heap()->global_ic_age()); 1574 info->ResetForNewContext(isolate()->heap()->global_ic_age());
1576 } 1575 }
1577 1576
1578 if (context_or_undefined->IsContext()) { 1577 if (context_or_undefined->IsContext()) {
1579 // Give compiler a chance to pre-initialize. 1578 // Give compiler a chance to pre-initialize.
1580 Compiler::PostInstantiation(result, pretenure); 1579 Compiler::PostInstantiation(result, pretenure);
1581 } 1580 }
1582 1581
1583 return result; 1582 return result;
1584 } 1583 }
1585 1584
1586 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 1585 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1587 Handle<Map> initial_map, Handle<SharedFunctionInfo> info, 1586 Handle<Map> initial_map, Handle<SharedFunctionInfo> info,
1588 Handle<Object> context_or_undefined, Handle<TypeFeedbackVector> vector, 1587 Handle<Object> context_or_undefined, Handle<Cell> vector,
1589 PretenureFlag pretenure) { 1588 PretenureFlag pretenure) {
1590 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); 1589 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type());
1591 Handle<JSFunction> result = 1590 Handle<JSFunction> result =
1592 NewFunction(initial_map, info, context_or_undefined, pretenure); 1591 NewFunction(initial_map, info, context_or_undefined, pretenure);
1593 1592
1594 result->set_feedback_vector(*vector); 1593 result->set_feedback_vector_cell(*vector);
1595 if (info->ic_age() != isolate()->heap()->global_ic_age()) { 1594 if (info->ic_age() != isolate()->heap()->global_ic_age()) {
1596 info->ResetForNewContext(isolate()->heap()->global_ic_age()); 1595 info->ResetForNewContext(isolate()->heap()->global_ic_age());
1597 } 1596 }
1598 1597
1599 if (context_or_undefined->IsContext()) { 1598 if (context_or_undefined->IsContext()) {
1600 // Give compiler a chance to pre-initialize. 1599 // Give compiler a chance to pre-initialize.
1601 Compiler::PostInstantiation(result, pretenure); 1600 Compiler::PostInstantiation(result, pretenure);
1602 } 1601 }
1603 1602
1604 return result; 1603 return result;
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 Handle<AccessorInfo> prototype = 2848 Handle<AccessorInfo> prototype =
2850 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); 2849 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs);
2851 Descriptor d = Descriptor::AccessorConstant( 2850 Descriptor d = Descriptor::AccessorConstant(
2852 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); 2851 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs);
2853 map->AppendDescriptor(&d); 2852 map->AppendDescriptor(&d);
2854 } 2853 }
2855 } 2854 }
2856 2855
2857 } // namespace internal 2856 } // namespace internal
2858 } // namespace v8 2857 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698