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

Side by Side Diff: src/factory.cc

Issue 2504153002: [TypeFeedbackVector] Root literal arrays in function literals slots (Closed)
Patch Set: REBASE. Created 4 years 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 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 PretenureFlag pretenure) { 1503 PretenureFlag pretenure) {
1504 int map_index = 1504 int map_index =
1505 Context::FunctionMapIndex(info->language_mode(), info->kind()); 1505 Context::FunctionMapIndex(info->language_mode(), info->kind());
1506 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index))); 1506 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index)));
1507 1507
1508 return NewFunctionFromSharedFunctionInfo(initial_map, info, context, 1508 return NewFunctionFromSharedFunctionInfo(initial_map, info, context,
1509 pretenure); 1509 pretenure);
1510 } 1510 }
1511 1511
1512 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 1512 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1513 Handle<SharedFunctionInfo> info, Handle<Context> context,
1514 Handle<LiteralsArray> literals, PretenureFlag pretenure) {
1515 int map_index =
1516 Context::FunctionMapIndex(info->language_mode(), info->kind());
1517 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index)));
1518
1519 return NewFunctionFromSharedFunctionInfo(initial_map, info, context, literals,
1520 pretenure);
1521 }
1522
1523 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1513 Handle<Map> initial_map, Handle<SharedFunctionInfo> info, 1524 Handle<Map> initial_map, Handle<SharedFunctionInfo> info,
1514 Handle<Object> context_or_undefined, PretenureFlag pretenure) { 1525 Handle<Object> context_or_undefined, PretenureFlag pretenure) {
1515 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); 1526 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type());
1516 Handle<JSFunction> result = 1527 Handle<JSFunction> result =
1517 NewFunction(initial_map, info, context_or_undefined, pretenure); 1528 NewFunction(initial_map, info, context_or_undefined, pretenure);
1518 1529
1519 if (info->ic_age() != isolate()->heap()->global_ic_age()) { 1530 if (info->ic_age() != isolate()->heap()->global_ic_age()) {
1520 info->ResetForNewContext(isolate()->heap()->global_ic_age()); 1531 info->ResetForNewContext(isolate()->heap()->global_ic_age());
1521 } 1532 }
1522 1533
1523 if (context_or_undefined->IsContext()) { 1534 if (context_or_undefined->IsContext()) {
1524 // Give compiler a chance to pre-initialize. 1535 // Give compiler a chance to pre-initialize.
1525 Compiler::PostInstantiation(result, pretenure); 1536 Compiler::PostInstantiation(result, pretenure);
1526 } 1537 }
1527 1538
1528 return result; 1539 return result;
1529 } 1540 }
1530 1541
1542 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1543 Handle<Map> initial_map, Handle<SharedFunctionInfo> info,
1544 Handle<Object> context_or_undefined, Handle<LiteralsArray> literals,
1545 PretenureFlag pretenure) {
1546 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type());
1547 Handle<JSFunction> result =
1548 NewFunction(initial_map, info, context_or_undefined, pretenure);
1549
1550 result->set_literals(*literals);
1551 if (info->ic_age() != isolate()->heap()->global_ic_age()) {
1552 info->ResetForNewContext(isolate()->heap()->global_ic_age());
1553 }
1554
1555 if (context_or_undefined->IsContext()) {
1556 // Give compiler a chance to pre-initialize.
1557 Compiler::PostInstantiation(result, pretenure);
1558 }
1559
1560 return result;
1561 }
1531 1562
1532 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { 1563 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
1533 Handle<FixedArray> array = NewFixedArray(length, TENURED); 1564 Handle<FixedArray> array = NewFixedArray(length, TENURED);
1534 array->set_map_no_write_barrier(*scope_info_map()); 1565 array->set_map_no_write_barrier(*scope_info_map());
1535 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); 1566 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array);
1536 return scope_info; 1567 return scope_info;
1537 } 1568 }
1538 1569
1539 Handle<ModuleInfo> Factory::NewModuleInfo() { 1570 Handle<ModuleInfo> Factory::NewModuleInfo() {
1540 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED); 1571 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED);
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); 2810 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map));
2780 iterator->set_initial_next(*next); 2811 iterator->set_initial_next(*next);
2781 iterator->set_array(*array); 2812 iterator->set_array(*array);
2782 iterator->set_index(0); 2813 iterator->set_index(0);
2783 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); 2814 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next);
2784 return iterator; 2815 return iterator;
2785 } 2816 }
2786 2817
2787 } // namespace internal 2818 } // namespace internal
2788 } // namespace v8 2819 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698