OLD | NEW |
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 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 PretenureFlag pretenure) { | 1524 PretenureFlag pretenure) { |
1525 int map_index = | 1525 int map_index = |
1526 Context::FunctionMapIndex(info->language_mode(), info->kind()); | 1526 Context::FunctionMapIndex(info->language_mode(), info->kind()); |
1527 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index))); | 1527 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index))); |
1528 | 1528 |
1529 return NewFunctionFromSharedFunctionInfo(initial_map, info, context, | 1529 return NewFunctionFromSharedFunctionInfo(initial_map, info, context, |
1530 pretenure); | 1530 pretenure); |
1531 } | 1531 } |
1532 | 1532 |
1533 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( | 1533 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
| 1534 Handle<SharedFunctionInfo> info, Handle<Context> context, |
| 1535 Handle<LiteralsArray> literals, PretenureFlag pretenure) { |
| 1536 int map_index = |
| 1537 Context::FunctionMapIndex(info->language_mode(), info->kind()); |
| 1538 Handle<Map> initial_map(Map::cast(context->native_context()->get(map_index))); |
| 1539 |
| 1540 return NewFunctionFromSharedFunctionInfo(initial_map, info, context, literals, |
| 1541 pretenure); |
| 1542 } |
| 1543 |
| 1544 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
1534 Handle<Map> initial_map, Handle<SharedFunctionInfo> info, | 1545 Handle<Map> initial_map, Handle<SharedFunctionInfo> info, |
1535 Handle<Object> context_or_undefined, PretenureFlag pretenure) { | 1546 Handle<Object> context_or_undefined, PretenureFlag pretenure) { |
1536 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); | 1547 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); |
1537 Handle<JSFunction> result = | 1548 Handle<JSFunction> result = |
1538 NewFunction(initial_map, info, context_or_undefined, pretenure); | 1549 NewFunction(initial_map, info, context_or_undefined, pretenure); |
1539 | 1550 |
1540 if (info->ic_age() != isolate()->heap()->global_ic_age()) { | 1551 if (info->ic_age() != isolate()->heap()->global_ic_age()) { |
1541 info->ResetForNewContext(isolate()->heap()->global_ic_age()); | 1552 info->ResetForNewContext(isolate()->heap()->global_ic_age()); |
1542 } | 1553 } |
1543 | 1554 |
1544 if (context_or_undefined->IsContext()) { | 1555 if (context_or_undefined->IsContext()) { |
1545 // Give compiler a chance to pre-initialize. | 1556 // Give compiler a chance to pre-initialize. |
1546 Compiler::PostInstantiation(result, pretenure); | 1557 Compiler::PostInstantiation(result, pretenure); |
1547 } | 1558 } |
1548 | 1559 |
1549 return result; | 1560 return result; |
1550 } | 1561 } |
1551 | 1562 |
| 1563 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
| 1564 Handle<Map> initial_map, Handle<SharedFunctionInfo> info, |
| 1565 Handle<Object> context_or_undefined, Handle<LiteralsArray> literals, |
| 1566 PretenureFlag pretenure) { |
| 1567 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); |
| 1568 Handle<JSFunction> result = |
| 1569 NewFunction(initial_map, info, context_or_undefined, pretenure); |
| 1570 |
| 1571 result->set_literals(*literals); |
| 1572 if (info->ic_age() != isolate()->heap()->global_ic_age()) { |
| 1573 info->ResetForNewContext(isolate()->heap()->global_ic_age()); |
| 1574 } |
| 1575 |
| 1576 if (context_or_undefined->IsContext()) { |
| 1577 // Give compiler a chance to pre-initialize. |
| 1578 Compiler::PostInstantiation(result, pretenure); |
| 1579 } |
| 1580 |
| 1581 return result; |
| 1582 } |
1552 | 1583 |
1553 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { | 1584 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { |
1554 Handle<FixedArray> array = NewFixedArray(length, TENURED); | 1585 Handle<FixedArray> array = NewFixedArray(length, TENURED); |
1555 array->set_map_no_write_barrier(*scope_info_map()); | 1586 array->set_map_no_write_barrier(*scope_info_map()); |
1556 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); | 1587 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); |
1557 return scope_info; | 1588 return scope_info; |
1558 } | 1589 } |
1559 | 1590 |
1560 Handle<ModuleInfo> Factory::NewModuleInfo() { | 1591 Handle<ModuleInfo> Factory::NewModuleInfo() { |
1561 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED); | 1592 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED); |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2780 Handle<AccessorInfo> prototype = | 2811 Handle<AccessorInfo> prototype = |
2781 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); | 2812 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); |
2782 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2813 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2783 prototype, rw_attribs); | 2814 prototype, rw_attribs); |
2784 map->AppendDescriptor(&d); | 2815 map->AppendDescriptor(&d); |
2785 } | 2816 } |
2786 } | 2817 } |
2787 | 2818 |
2788 } // namespace internal | 2819 } // namespace internal |
2789 } // namespace v8 | 2820 } // namespace v8 |
OLD | NEW |