Revision: 20873
Author: [email protected]
Date: Tue Apr 22 08:30:09 2014 UTC
Log: Set code on the SharedFunctionInfo before creating the function.
BUG=
[email protected]
Review URL: https://codereview.chromium.org/238773009
http://code.google.com/p/v8/source/detail?r=20873
Modified:
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/factory.h
/branches/bleeding_edge/test/cctest/test-alloc.cc
/branches/bleeding_edge/test/cctest/test-heap.cc
/branches/bleeding_edge/test/cctest/test-mark-compact.cc
/branches/bleeding_edge/test/cctest/test-weakmaps.cc
/branches/bleeding_edge/test/cctest/test-weaksets.cc
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Thu Apr 17 17:45:32 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Tue Apr 22 08:30:09 2014 UTC
@@ -355,14 +355,14 @@
Factory* factory = isolate->factory();
Handle<String> internalized_name = factory->InternalizeUtf8String(name);
Handle<Code> call_code =
Handle<Code>(isolate->builtins()->builtin(call));
- Handle<JSFunction> function = prototype.is_null() ?
- factory->NewFunctionWithoutPrototype(internalized_name, call_code) :
- factory->NewFunctionWithPrototype(internalized_name,
- type,
- instance_size,
- prototype,
- call_code,
- install_initial_map);
+ Handle<JSFunction> function = prototype.is_null()
+ ? factory->NewFunction(internalized_name, call_code)
+ : factory->NewFunctionWithPrototype(internalized_name,
+ type,
+ instance_size,
+ prototype,
+ call_code,
+ install_initial_map);
PropertyAttributes attributes;
if (target->IsJSBuiltinsObject()) {
attributes =
@@ -458,8 +458,8 @@
Handle<String> object_name = factory->Object_string();
{ // --- O b j e c t ---
- Handle<JSFunction> object_fun =
- factory->NewFunction(object_name, factory->null_value());
+ Handle<JSFunction> object_fun = factory->NewFunctionWithPrototype(
+ object_name, factory->null_value());
Handle<Map> object_function_map =
factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
object_fun->set_initial_map(*object_function_map);
@@ -485,8 +485,7 @@
Handle<String> empty_string =
factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
Handle<Code>
code(isolate->builtins()->builtin(Builtins::kEmptyFunction));
- Handle<JSFunction> empty_function =
- factory->NewFunctionWithoutPrototype(empty_string, code);
+ Handle<JSFunction> empty_function = factory->NewFunction(empty_string,
code);
// --- E m p t y ---
Handle<String> source = factory->NewStringFromStaticAscii("() {}");
@@ -564,8 +563,7 @@
STATIC_ASCII_VECTOR("ThrowTypeError"));
Handle<Code> code(isolate()->builtins()->builtin(
Builtins::kStrictModePoisonPill));
- throw_type_error_function =
- factory()->NewFunctionWithoutPrototype(name, code);
+ throw_type_error_function = factory()->NewFunction(name, code);
throw_type_error_function->set_map(native_context()->sloppy_function_map());
throw_type_error_function->shared()->DontAdaptArguments();
@@ -1016,8 +1014,8 @@
{ // -- J S O N
Handle<String> name = factory->InternalizeUtf8String("JSON");
- Handle<JSFunction> cons = factory->NewFunction(name,
-
factory->the_hole_value());
+ Handle<JSFunction> cons = factory->NewFunctionWithPrototype(
+ name, factory->the_hole_value());
JSFunction::SetInstancePrototype(cons,
Handle<Object>(native_context()->initial_object_prototype(),
isolate));
cons->SetInstanceClassName(*name);
@@ -1063,11 +1061,9 @@
// class_name equals 'Arguments'.
Handle<String> arguments_string = factory->InternalizeOneByteString(
STATIC_ASCII_VECTOR("Arguments"));
- Handle<Code> code = Handle<Code>(
- isolate->builtins()->builtin(Builtins::kIllegal));
- Handle<JSObject> prototype =
- Handle<JSObject>(
-
JSObject::cast(native_context()->object_function()->prototype()));
+ Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal));
+ Handle<JSObject> prototype(
+ JSObject::cast(native_context()->object_function()->prototype()));
Handle<JSFunction> function =
factory->NewFunctionWithPrototype(arguments_string,
@@ -1662,9 +1658,8 @@
set_builtins(*builtins);
// Create a bridge function that has context in the native context.
- Handle<JSFunction> bridge =
- factory()->NewFunction(factory()->empty_string(),
- factory()->undefined_value());
+ Handle<JSFunction> bridge = factory()->NewFunctionWithPrototype(
+ factory()->empty_string(), factory()->undefined_value());
ASSERT(bridge->context() == *isolate()->native_context());
// Allocate the builtins context.
=======================================
--- /branches/bleeding_edge/src/factory.cc Thu Apr 17 17:45:32 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc Tue Apr 22 08:30:09 2014 UTC
@@ -1273,12 +1273,7 @@
Handle<Code> code,
bool force_initial_map) {
// Allocate the function
- Handle<JSFunction> function = NewFunction(name, the_hole_value());
-
- // Set up the code pointer in both the shared function info and in
- // the function itself.
- function->shared()->set_code(*code);
- function->set_code(*code);
+ Handle<JSFunction> function = NewFunction(name, code, the_hole_value());
if (force_initial_map ||
type != JS_OBJECT_TYPE ||
@@ -1304,12 +1299,7 @@
Handle<Code> code,
bool
force_initial_map) {
// Allocate the function.
- Handle<JSFunction> function = NewFunction(name, prototype);
-
- // Set up the code pointer in both the shared function info and in
- // the function itself.
- function->shared()->set_code(*code);
- function->set_code(*code);
+ Handle<JSFunction> function = NewFunction(name, code, prototype);
if (force_initial_map ||
type != JS_OBJECT_TYPE ||
@@ -2041,19 +2031,20 @@
Handle<JSFunction> Factory::NewFunction(Handle<String> name,
- Handle<Object> prototype) {
+ Handle<Code> code,
+ MaybeHandle<Object>
maybe_prototype) {
Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
+ info->set_code(*code);
Handle<Context> context(isolate()->context()->native_context());
- return NewFunction(info, context, prototype);
+ return NewFunction(info, context, maybe_prototype);
}
-Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String>
name,
- Handle<Code> code)
{
+Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
+ Handle<Object>
prototype) {
Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
- info->set_code(*code);
Handle<Context> context(isolate()->context()->native_context());
- return NewFunction(info, context, MaybeHandle<Object>());
+ return NewFunction(info, context, prototype);
}
=======================================
--- /branches/bleeding_edge/src/factory.h Thu Apr 17 17:45:32 2014 UTC
+++ /branches/bleeding_edge/src/factory.h Tue Apr 22 08:30:09 2014 UTC
@@ -442,7 +442,12 @@
void BecomeJSFunction(Handle<JSReceiver> object);
Handle<JSFunction> NewFunction(Handle<String> name,
- Handle<Object> prototype);
+ Handle<Code> code,
+ MaybeHandle<Object> maybe_prototype =
+ MaybeHandle<Object>());
+
+ Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name,
+ Handle<Object> prototype);
Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
Handle<SharedFunctionInfo> function_info,
@@ -462,9 +467,6 @@
Handle<Code> code,
bool force_initial_map);
- Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name,
- Handle<Code> code);
-
// Create a serialized scope info.
Handle<ScopeInfo> NewScopeInfo(int length);
=======================================
--- /branches/bleeding_edge/test/cctest/test-alloc.cc Thu Apr 17 14:58:03
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-alloc.cc Tue Apr 22 08:30:09
2014 UTC
@@ -122,8 +122,8 @@
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate());
env->Enter();
- Handle<JSFunction> function =
- factory->NewFunction(factory->function_string(),
factory->null_value());
+ Handle<JSFunction> function = factory->NewFunctionWithPrototype(
+ factory->function_string(), factory->null_value());
// Force the creation of an initial map and set the code to
// something empty.
factory->NewJSObject(function);
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Thu Apr 17 13:53:06
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-heap.cc Tue Apr 22 08:30:09
2014 UTC
@@ -267,8 +267,8 @@
{
HandleScope inner_scope(isolate);
// Allocate a function and keep it in global object's property.
- Handle<JSFunction> function =
- factory->NewFunction(name, factory->undefined_value());
+ Handle<JSFunction> function = factory->NewFunctionWithPrototype(
+ name, factory->undefined_value());
Handle<Map> initial_map =
factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
@@ -626,8 +626,8 @@
v8::HandleScope sc(CcTest::isolate());
Handle<String> name = factory->InternalizeUtf8String("theFunction");
- Handle<JSFunction> function =
- factory->NewFunction(name, factory->undefined_value());
+ Handle<JSFunction> function = factory->NewFunctionWithPrototype(
+ name, factory->undefined_value());
Handle<Map> initial_map =
factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
@@ -725,8 +725,8 @@
v8::HandleScope sc(CcTest::isolate());
Handle<String> name = factory->InternalizeUtf8String("theFunction");
- Handle<JSFunction> function =
- factory->NewFunction(name, factory->undefined_value());
+ Handle<JSFunction> function = factory->NewFunctionWithPrototype(
+ name, factory->undefined_value());
Handle<Map> initial_map =
factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
=======================================
--- /branches/bleeding_edge/test/cctest/test-mark-compact.cc Thu Apr 17
13:58:51 2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-mark-compact.cc Tue Apr 22
08:30:09 2014 UTC
@@ -159,7 +159,7 @@
{ HandleScope scope(isolate);
// allocate a garbage
Handle<String> func_name =
factory->InternalizeUtf8String("theFunction");
- Handle<JSFunction> function = factory->NewFunction(
+ Handle<JSFunction> function = factory->NewFunctionWithPrototype(
func_name, factory->undefined_value());
Handle<Map> initial_map = factory->NewMap(
JS_OBJECT_TYPE, JSObject::kHeaderSize);
=======================================
--- /branches/bleeding_edge/test/cctest/test-weakmaps.cc Mon Apr 14
13:52:41 2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-weakmaps.cc Tue Apr 22
08:30:09 2014 UTC
@@ -187,8 +187,8 @@
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
- Handle<JSFunction> function =
- factory->NewFunction(factory->function_string(),
factory->null_value());
+ Handle<JSFunction> function = factory->NewFunctionWithPrototype(
+ factory->function_string(), factory->null_value());
Handle<JSObject> key = factory->NewJSObject(function);
Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
@@ -227,8 +227,8 @@
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
- Handle<JSFunction> function =
- factory->NewFunction(factory->function_string(),
factory->null_value());
+ Handle<JSFunction> function = factory->NewFunctionWithPrototype(
+ factory->function_string(), factory->null_value());
// Start second old-space page so that keys land on evacuation candidate.
Page* first_page = heap->old_pointer_space()->anchor()->next_page();
=======================================
--- /branches/bleeding_edge/test/cctest/test-weaksets.cc Mon Apr 14
13:52:41 2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-weaksets.cc Tue Apr 22
08:30:09 2014 UTC
@@ -187,8 +187,8 @@
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
- Handle<JSFunction> function =
- factory->NewFunction(factory->function_string(),
factory->null_value());
+ Handle<JSFunction> function = factory->NewFunctionWithPrototype(
+ factory->function_string(), factory->null_value());
Handle<JSObject> key = factory->NewJSObject(function);
Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate);
@@ -227,8 +227,8 @@
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
- Handle<JSFunction> function =
- factory->NewFunction(factory->function_string(),
factory->null_value());
+ Handle<JSFunction> function = factory->NewFunctionWithPrototype(
+ factory->function_string(), factory->null_value());
// Start second old-space page so that keys land on evacuation candidate.
Page* first_page = heap->old_pointer_space()->anchor()->next_page();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.