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

Side by Side Diff: src/factory.cc

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/factory.h ('k') | src/flag-definitions.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 ASSERT(0 <= size); 74 ASSERT(0 <= size);
75 CALL_HEAP_FUNCTION( 75 CALL_HEAP_FUNCTION(
76 isolate(), 76 isolate(),
77 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure), 77 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure),
78 FixedDoubleArray); 78 FixedDoubleArray);
79 } 79 }
80 80
81 81
82 Handle<ConstantPoolArray> Factory::NewConstantPoolArray( 82 Handle<ConstantPoolArray> Factory::NewConstantPoolArray(
83 int number_of_int64_entries, 83 int number_of_int64_entries,
84 int number_of_ptr_entries, 84 int number_of_code_ptr_entries,
85 int number_of_heap_ptr_entries,
85 int number_of_int32_entries) { 86 int number_of_int32_entries) {
86 ASSERT(number_of_int64_entries > 0 || number_of_ptr_entries > 0 || 87 ASSERT(number_of_int64_entries > 0 || number_of_code_ptr_entries > 0 ||
87 number_of_int32_entries > 0); 88 number_of_heap_ptr_entries > 0 || number_of_int32_entries > 0);
88 CALL_HEAP_FUNCTION( 89 CALL_HEAP_FUNCTION(
89 isolate(), 90 isolate(),
90 isolate()->heap()->AllocateConstantPoolArray(number_of_int64_entries, 91 isolate()->heap()->AllocateConstantPoolArray(number_of_int64_entries,
91 number_of_ptr_entries, 92 number_of_code_ptr_entries,
93 number_of_heap_ptr_entries,
92 number_of_int32_entries), 94 number_of_int32_entries),
93 ConstantPoolArray); 95 ConstantPoolArray);
94 } 96 }
95 97
96 98
97 Handle<NameDictionary> Factory::NewNameDictionary(int at_least_space_for) { 99 Handle<NameDictionary> Factory::NewNameDictionary(int at_least_space_for) {
98 ASSERT(0 <= at_least_space_for); 100 ASSERT(0 <= at_least_space_for);
99 CALL_HEAP_FUNCTION(isolate(), 101 CALL_HEAP_FUNCTION(isolate(),
100 NameDictionary::Allocate(isolate()->heap(), 102 NameDictionary::Allocate(isolate()->heap(),
101 at_least_space_for), 103 at_least_space_for),
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 heap->set_last_script_id(Smi::FromInt(id)); 695 heap->set_last_script_id(Smi::FromInt(id));
694 696
695 // Create and initialize script object. 697 // Create and initialize script object.
696 Handle<Foreign> wrapper = NewForeign(0, TENURED); 698 Handle<Foreign> wrapper = NewForeign(0, TENURED);
697 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); 699 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE));
698 script->set_source(*source); 700 script->set_source(*source);
699 script->set_name(heap->undefined_value()); 701 script->set_name(heap->undefined_value());
700 script->set_id(Smi::FromInt(id)); 702 script->set_id(Smi::FromInt(id));
701 script->set_line_offset(Smi::FromInt(0)); 703 script->set_line_offset(Smi::FromInt(0));
702 script->set_column_offset(Smi::FromInt(0)); 704 script->set_column_offset(Smi::FromInt(0));
703 script->set_data(heap->undefined_value());
704 script->set_context_data(heap->undefined_value()); 705 script->set_context_data(heap->undefined_value());
705 script->set_type(Smi::FromInt(Script::TYPE_NORMAL)); 706 script->set_type(Smi::FromInt(Script::TYPE_NORMAL));
706 script->set_wrapper(*wrapper); 707 script->set_wrapper(*wrapper);
707 script->set_line_ends(heap->undefined_value()); 708 script->set_line_ends(heap->undefined_value());
708 script->set_eval_from_shared(heap->undefined_value()); 709 script->set_eval_from_shared(heap->undefined_value());
709 script->set_eval_from_instructions_offset(Smi::FromInt(0)); 710 script->set_eval_from_instructions_offset(Smi::FromInt(0));
710 script->set_flags(Smi::FromInt(0)); 711 script->set_flags(Smi::FromInt(0));
711 712
712 return script; 713 return script;
713 } 714 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 *function_info, 920 *function_info,
920 isolate()->heap()->the_hole_value(), 921 isolate()->heap()->the_hole_value(),
921 pretenure), 922 pretenure),
922 JSFunction); 923 JSFunction);
923 } 924 }
924 925
925 926
926 static Handle<Map> MapForNewFunction(Isolate *isolate, 927 static Handle<Map> MapForNewFunction(Isolate *isolate,
927 Handle<SharedFunctionInfo> function_info) { 928 Handle<SharedFunctionInfo> function_info) {
928 Context *context = isolate->context()->native_context(); 929 Context *context = isolate->context()->native_context();
929 int map_index = Context::FunctionMapIndex(function_info->language_mode(), 930 int map_index = Context::FunctionMapIndex(function_info->strict_mode(),
930 function_info->is_generator()); 931 function_info->is_generator());
931 return Handle<Map>(Map::cast(context->get(map_index))); 932 return Handle<Map>(Map::cast(context->get(map_index)));
932 } 933 }
933 934
934 935
935 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 936 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
936 Handle<SharedFunctionInfo> function_info, 937 Handle<SharedFunctionInfo> function_info,
937 Handle<Context> context, 938 Handle<Context> context,
938 PretenureFlag pretenure) { 939 PretenureFlag pretenure) {
939 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo( 940 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo(
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 initial_map->set_constructor(*function); 1243 initial_map->set_constructor(*function);
1243 } 1244 }
1244 1245
1245 JSFunction::SetPrototype(function, prototype); 1246 JSFunction::SetPrototype(function, prototype);
1246 return function; 1247 return function;
1247 } 1248 }
1248 1249
1249 1250
1250 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, 1251 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name,
1251 Handle<Code> code) { 1252 Handle<Code> code) {
1252 Handle<JSFunction> function = NewFunctionWithoutPrototype(name, 1253 Handle<JSFunction> function = NewFunctionWithoutPrototype(name, SLOPPY);
1253 CLASSIC_MODE);
1254 function->shared()->set_code(*code); 1254 function->shared()->set_code(*code);
1255 function->set_code(*code); 1255 function->set_code(*code);
1256 ASSERT(!function->has_initial_map()); 1256 ASSERT(!function->has_initial_map());
1257 ASSERT(!function->has_prototype()); 1257 ASSERT(!function->has_prototype());
1258 return function; 1258 return function;
1259 } 1259 }
1260 1260
1261 1261
1262 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { 1262 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
1263 CALL_HEAP_FUNCTION( 1263 CALL_HEAP_FUNCTION(
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 isolate()->heap()->ReinitializeJSReceiver( 1535 isolate()->heap()->ReinitializeJSReceiver(
1536 *object, JS_FUNCTION_TYPE, JSFunction::kSize)); 1536 *object, JS_FUNCTION_TYPE, JSFunction::kSize));
1537 } 1537 }
1538 1538
1539 1539
1540 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( 1540 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
1541 Handle<String> name, 1541 Handle<String> name,
1542 int number_of_literals, 1542 int number_of_literals,
1543 bool is_generator, 1543 bool is_generator,
1544 Handle<Code> code, 1544 Handle<Code> code,
1545 Handle<ScopeInfo> scope_info) { 1545 Handle<ScopeInfo> scope_info,
1546 Handle<FixedArray> feedback_vector) {
1546 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); 1547 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name);
1547 shared->set_code(*code); 1548 shared->set_code(*code);
1548 shared->set_scope_info(*scope_info); 1549 shared->set_scope_info(*scope_info);
1550 shared->set_feedback_vector(*feedback_vector);
1549 int literals_array_size = number_of_literals; 1551 int literals_array_size = number_of_literals;
1550 // If the function contains object, regexp or array literals, 1552 // If the function contains object, regexp or array literals,
1551 // allocate extra space for a literals array prefix containing the 1553 // allocate extra space for a literals array prefix containing the
1552 // context. 1554 // context.
1553 if (number_of_literals > 0) { 1555 if (number_of_literals > 0) {
1554 literals_array_size += JSFunction::kLiteralsPrefixSize; 1556 literals_array_size += JSFunction::kLiteralsPrefixSize;
1555 } 1557 }
1556 shared->set_num_literals(literals_array_size); 1558 shared->set_num_literals(literals_array_size);
1557 if (is_generator) { 1559 if (is_generator) {
1558 shared->set_instance_class_name(isolate()->heap()->Generator_string()); 1560 shared->set_instance_class_name(isolate()->heap()->Generator_string());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 dictionary->AtNumberPut(key, *value), 1619 dictionary->AtNumberPut(key, *value),
1618 UnseededNumberDictionary); 1620 UnseededNumberDictionary);
1619 } 1621 }
1620 1622
1621 1623
1622 Handle<JSFunction> Factory::NewFunctionHelper(Handle<String> name, 1624 Handle<JSFunction> Factory::NewFunctionHelper(Handle<String> name,
1623 Handle<Object> prototype) { 1625 Handle<Object> prototype) {
1624 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); 1626 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
1625 CALL_HEAP_FUNCTION( 1627 CALL_HEAP_FUNCTION(
1626 isolate(), 1628 isolate(),
1627 isolate()->heap()->AllocateFunction(*isolate()->function_map(), 1629 isolate()->heap()->AllocateFunction(*isolate()->sloppy_function_map(),
1628 *function_share, 1630 *function_share,
1629 *prototype), 1631 *prototype),
1630 JSFunction); 1632 JSFunction);
1631 } 1633 }
1632 1634
1633 1635
1634 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 1636 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
1635 Handle<Object> prototype) { 1637 Handle<Object> prototype) {
1636 Handle<JSFunction> fun = NewFunctionHelper(name, prototype); 1638 Handle<JSFunction> fun = NewFunctionHelper(name, prototype);
1637 fun->set_context(isolate()->context()->native_context()); 1639 fun->set_context(isolate()->context()->native_context());
1638 return fun; 1640 return fun;
1639 } 1641 }
1640 1642
1641 1643
1642 Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper( 1644 Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper(
1643 Handle<String> name, 1645 Handle<String> name,
1644 LanguageMode language_mode) { 1646 StrictMode strict_mode) {
1645 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); 1647 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
1646 Handle<Map> map = (language_mode == CLASSIC_MODE) 1648 Handle<Map> map = strict_mode == SLOPPY
1647 ? isolate()->function_without_prototype_map() 1649 ? isolate()->sloppy_function_without_prototype_map()
1648 : isolate()->strict_mode_function_without_prototype_map(); 1650 : isolate()->strict_function_without_prototype_map();
1649 CALL_HEAP_FUNCTION(isolate(), 1651 CALL_HEAP_FUNCTION(isolate(),
1650 isolate()->heap()->AllocateFunction( 1652 isolate()->heap()->AllocateFunction(
1651 *map, 1653 *map,
1652 *function_share, 1654 *function_share,
1653 *the_hole_value()), 1655 *the_hole_value()),
1654 JSFunction); 1656 JSFunction);
1655 } 1657 }
1656 1658
1657 1659
1658 Handle<JSFunction> Factory::NewFunctionWithoutPrototype( 1660 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(
1659 Handle<String> name, 1661 Handle<String> name,
1660 LanguageMode language_mode) { 1662 StrictMode strict_mode) {
1661 Handle<JSFunction> fun = 1663 Handle<JSFunction> fun = NewFunctionWithoutPrototypeHelper(name, strict_mode);
1662 NewFunctionWithoutPrototypeHelper(name, language_mode);
1663 fun->set_context(isolate()->context()->native_context()); 1664 fun->set_context(isolate()->context()->native_context());
1664 return fun; 1665 return fun;
1665 } 1666 }
1666 1667
1667 1668
1668 Handle<Object> Factory::ToObject(Handle<Object> object) { 1669 Handle<Object> Factory::ToObject(Handle<Object> object) {
1669 CALL_HEAP_FUNCTION(isolate(), object->ToObject(isolate()), Object); 1670 CALL_HEAP_FUNCTION(isolate(), object->ToObject(isolate()), Object);
1670 } 1671 }
1671 1672
1672 1673
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 return Handle<Object>::null(); 1991 return Handle<Object>::null();
1991 } 1992 }
1992 1993
1993 1994
1994 Handle<Object> Factory::ToBoolean(bool value) { 1995 Handle<Object> Factory::ToBoolean(bool value) {
1995 return value ? true_value() : false_value(); 1996 return value ? true_value() : false_value();
1996 } 1997 }
1997 1998
1998 1999
1999 } } // namespace v8::internal 2000 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698