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

Unified Diff: src/factory.cc

Issue 669240: - Remove function boilerplate objects and use SharedFunctionInfos in... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Committed Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.h ('k') | src/fast-codegen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
===================================================================
--- src/factory.cc (revision 4210)
+++ src/factory.cc (working copy)
@@ -282,31 +282,26 @@
}
-Handle<JSFunction> Factory::BaseNewFunctionFromBoilerplate(
- Handle<JSFunction> boilerplate,
+Handle<JSFunction> Factory::BaseNewFunctionFromSharedFunctionInfo(
+ Handle<SharedFunctionInfo> function_info,
Handle<Map> function_map,
PretenureFlag pretenure) {
- ASSERT(boilerplate->IsBoilerplate());
- ASSERT(!boilerplate->has_initial_map());
- ASSERT(!boilerplate->has_prototype());
- ASSERT(boilerplate->properties() == Heap::empty_fixed_array());
- ASSERT(boilerplate->elements() == Heap::empty_fixed_array());
CALL_HEAP_FUNCTION(Heap::AllocateFunction(*function_map,
- boilerplate->shared(),
+ *function_info,
Heap::the_hole_value(),
pretenure),
JSFunction);
}
-Handle<JSFunction> Factory::NewFunctionFromBoilerplate(
- Handle<JSFunction> boilerplate,
+Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
+ Handle<SharedFunctionInfo> function_info,
Handle<Context> context,
PretenureFlag pretenure) {
- Handle<JSFunction> result = BaseNewFunctionFromBoilerplate(
- boilerplate, Top::function_map(), pretenure);
+ Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo(
+ function_info, Top::function_map(), pretenure);
result->set_context(*context);
- int number_of_literals = boilerplate->NumberOfLiterals();
+ int number_of_literals = function_info->num_literals();
Handle<FixedArray> literals =
Factory::NewFixedArray(number_of_literals, pretenure);
if (number_of_literals > 0) {
@@ -490,36 +485,6 @@
}
-Handle<JSFunction> Factory::NewFunctionBoilerplate(Handle<String> name,
- int number_of_literals,
- Handle<Code> code) {
- Handle<JSFunction> function = NewFunctionBoilerplate(name);
- function->set_code(*code);
- int literals_array_size = number_of_literals;
- // If the function contains object, regexp or array literals,
- // allocate extra space for a literals array prefix containing the
- // object, regexp and array constructor functions.
- if (number_of_literals > 0) {
- literals_array_size += JSFunction::kLiteralsPrefixSize;
- }
- Handle<FixedArray> literals =
- Factory::NewFixedArray(literals_array_size, TENURED);
- function->set_literals(*literals);
- ASSERT(!function->has_initial_map());
- ASSERT(!function->has_prototype());
- return function;
-}
-
-
-Handle<JSFunction> Factory::NewFunctionBoilerplate(Handle<String> name) {
- Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name);
- CALL_HEAP_FUNCTION(Heap::AllocateFunction(Heap::boilerplate_function_map(),
- *shared,
- Heap::the_hole_value()),
- JSFunction);
-}
-
-
Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
InstanceType type,
int instance_size,
@@ -686,6 +651,22 @@
}
+Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
+ Handle<String> name, int number_of_literals, Handle<Code> code) {
+ Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name);
+ shared->set_code(*code);
+ int literals_array_size = number_of_literals;
+ // If the function contains object, regexp or array literals,
+ // allocate extra space for a literals array prefix containing the
+ // context.
+ if (number_of_literals > 0) {
+ literals_array_size += JSFunction::kLiteralsPrefixSize;
+ }
+ shared->set_num_literals(literals_array_size);
+ return shared;
+}
+
+
Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(Handle<String> name) {
CALL_HEAP_FUNCTION(Heap::AllocateSharedFunctionInfo(*name),
SharedFunctionInfo);
« no previous file with comments | « src/factory.h ('k') | src/fast-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698