Version 2.1.8
Added fine-grained garbage collection callbacks to the API.
Performance improvements on all platforms.
git-svn-id: http://v8.googlecode.com/svn/trunk@4238 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/factory.cc b/src/factory.cc
index 45124e6..dbcb4ec 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -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);