Revision: 21235
Author: [email protected]
Date: Fri May 9 16:39:33 2014 UTC
Log: Replace NewFunctionWithPrototype(name, prototype) by
NewFunction(name)
BUG=
[email protected]
Review URL: https://codereview.chromium.org/268063008
http://code.google.com/p/v8/source/detail?r=21235
Modified:
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/factory.h
/branches/bleeding_edge/src/runtime.cc
/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 Fri May 9 16:34:58 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Fri May 9 16:39:33 2014 UTC
@@ -461,8 +461,7 @@
Handle<String> object_name = factory->Object_string();
{ // --- O b j e c t ---
- Handle<JSFunction> object_fun = factory->NewFunctionWithPrototype(
- object_name, factory->null_value());
+ Handle<JSFunction> object_fun = factory->NewFunction(object_name);
Handle<Map> object_function_map =
factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
object_fun->set_initial_map(*object_function_map);
@@ -488,7 +487,8 @@
Handle<String> empty_string =
factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
Handle<Code>
code(isolate->builtins()->builtin(Builtins::kEmptyFunction));
- Handle<JSFunction> empty_function = factory->NewFunction(empty_string,
code);
+ Handle<JSFunction> empty_function = factory->NewFunction(
+ empty_string, MaybeHandle<Object>(), code);
// --- E m p t y ---
Handle<String> source = factory->NewStringFromStaticAscii("() {}");
@@ -569,7 +569,8 @@
STATIC_ASCII_VECTOR("ThrowTypeError"));
Handle<Code> code(isolate()->builtins()->builtin(
Builtins::kStrictModePoisonPill));
- throw_type_error_function = factory()->NewFunction(name, code);
+ throw_type_error_function = factory()->NewFunction(
+ name, MaybeHandle<Object>(), code);
throw_type_error_function->set_map(native_context()->sloppy_function_map());
throw_type_error_function->shared()->DontAdaptArguments();
@@ -1026,8 +1027,7 @@
{ // -- J S O N
Handle<String> name = factory->InternalizeUtf8String("JSON");
- Handle<JSFunction> cons = factory->NewFunctionWithPrototype(
- name, factory->the_hole_value());
+ Handle<JSFunction> cons = factory->NewFunction(name);
JSFunction::SetInstancePrototype(cons,
Handle<Object>(native_context()->initial_object_prototype(),
isolate));
cons->SetInstanceClassName(*name);
@@ -1669,8 +1669,7 @@
set_builtins(*builtins);
// Create a bridge function that has context in the native context.
- Handle<JSFunction> bridge = factory()->NewFunctionWithPrototype(
- factory()->empty_string(), factory()->undefined_value());
+ Handle<JSFunction> bridge =
factory()->NewFunction(factory()->empty_string());
ASSERT(bridge->context() == *isolate()->native_context());
// Allocate the builtins context.
=======================================
--- /branches/bleeding_edge/src/factory.cc Fri May 9 16:34:58 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc Fri May 9 16:39:33 2014 UTC
@@ -1203,11 +1203,14 @@
Handle<JSFunction> Factory::NewFunction(Handle<String> name,
- Handle<Code> code,
- MaybeHandle<Object>
maybe_prototype) {
+ MaybeHandle<Object>
maybe_prototype,
+ MaybeHandle<Code> maybe_code) {
Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
ASSERT(info->strict_mode() == SLOPPY);
- info->set_code(*code);
+ Handle<Code> code;
+ if (maybe_code.ToHandle(&code)) {
+ info->set_code(*code);
+ }
Handle<Context> context(isolate()->context()->native_context());
Handle<Map> map = maybe_prototype.is_null()
? isolate()->sloppy_function_without_prototype_map()
@@ -1221,15 +1224,8 @@
}
-Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
- Handle<Object>
prototype) {
- Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
- ASSERT(info->strict_mode() == SLOPPY);
- Handle<Context> context(isolate()->context()->native_context());
- Handle<Map> map = isolate()->sloppy_function_map();
- Handle<JSFunction> result = NewFunction(map, info, context);
- result->set_prototype_or_initial_map(*prototype);
- return result;
+Handle<JSFunction> Factory::NewFunction(Handle<String> name) {
+ return NewFunction(name, the_hole_value(), MaybeHandle<Code>());
}
@@ -1240,7 +1236,7 @@
Handle<Code> code,
bool force_initial_map) {
// Allocate the function
- Handle<JSFunction> function = NewFunction(name, code, maybe_prototype);
+ Handle<JSFunction> function = NewFunction(name, maybe_prototype, code);
if (force_initial_map ||
type != JS_OBJECT_TYPE ||
=======================================
--- /branches/bleeding_edge/src/factory.h Fri May 9 16:34:58 2014 UTC
+++ /branches/bleeding_edge/src/factory.h Fri May 9 16:39:33 2014 UTC
@@ -452,12 +452,9 @@
void BecomeJSFunction(Handle<JSReceiver> object);
Handle<JSFunction> NewFunction(Handle<String> name,
- Handle<Code> code,
- MaybeHandle<Object> maybe_prototype =
- MaybeHandle<Object>());
-
- Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name,
- Handle<Object> prototype);
+ MaybeHandle<Object> maybe_prototype,
+ MaybeHandle<Code> maybe_code);
+ Handle<JSFunction> NewFunction(Handle<String> name);
Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
Handle<SharedFunctionInfo> function_info,
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri May 9 13:01:50 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Fri May 9 16:39:33 2014 UTC
@@ -2806,13 +2806,8 @@
Builtins::Name builtin_name) {
Handle<String> key = isolate->factory()->InternalizeUtf8String(name);
Handle<Code> code(isolate->builtins()->builtin(builtin_name));
- Handle<JSFunction> optimized =
- isolate->factory()->NewFunction(MaybeHandle<Object>(),
- key,
- JS_OBJECT_TYPE,
- JSObject::kHeaderSize,
- code,
- false);
+ Handle<JSFunction> optimized = isolate->factory()->NewFunction(
+ key, MaybeHandle<Object>(), code);
optimized->shared()->DontAdaptArguments();
JSReceiver::SetProperty(holder, key, optimized, NONE, STRICT).Assert();
return optimized;
=======================================
--- /branches/bleeding_edge/test/cctest/test-alloc.cc Wed Apr 30 12:25:18
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-alloc.cc Fri May 9 16:39:33
2014 UTC
@@ -137,8 +137,8 @@
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate());
env->Enter();
- Handle<JSFunction> function = factory->NewFunctionWithPrototype(
- factory->function_string(), factory->null_value());
+ Handle<JSFunction> function = factory->NewFunction(
+ factory->function_string());
// 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 Fri May 9 08:38:27
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-heap.cc Fri May 9 16:39:33
2014 UTC
@@ -261,11 +261,7 @@
{
HandleScope inner_scope(isolate);
// Allocate a function and keep it in global object's property.
- 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);
+ Handle<JSFunction> function = factory->NewFunction(name);
JSReceiver::SetProperty(global, name, function, NONE, SLOPPY).Check();
// Allocate an object. Unrooted after leaving the scope.
Handle<JSObject> obj = factory->NewJSObject(function);
@@ -624,11 +620,7 @@
v8::HandleScope sc(CcTest::isolate());
Handle<String> name = factory->InternalizeUtf8String("theFunction");
- 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);
+ Handle<JSFunction> function = factory->NewFunction(name);
Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
@@ -723,14 +715,11 @@
v8::HandleScope sc(CcTest::isolate());
Handle<String> name = factory->InternalizeUtf8String("theFunction");
- 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);
+ Handle<JSFunction> function = factory->NewFunction(name);
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
Handle<JSObject> obj = factory->NewJSObject(function);
+ Handle<Map> initial_map(function->initial_map());
// Set a propery
Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
=======================================
--- /branches/bleeding_edge/test/cctest/test-mark-compact.cc Fri May 9
08:38:27 2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-mark-compact.cc Fri May 9
16:39:33 2014 UTC
@@ -156,11 +156,7 @@
{ HandleScope scope(isolate);
// allocate a garbage
Handle<String> func_name =
factory->InternalizeUtf8String("theFunction");
- Handle<JSFunction> function = factory->NewFunctionWithPrototype(
- func_name, factory->undefined_value());
- Handle<Map> initial_map = factory->NewMap(
- JS_OBJECT_TYPE, JSObject::kHeaderSize);
- function->set_initial_map(*initial_map);
+ Handle<JSFunction> function = factory->NewFunction(func_name);
JSReceiver::SetProperty(global, func_name, function, NONE,
SLOPPY).Check();
factory->NewJSObject(function);
=======================================
--- /branches/bleeding_edge/test/cctest/test-weakmaps.cc Fri Apr 25
13:06:21 2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-weakmaps.cc Fri May 9
16:39:33 2014 UTC
@@ -185,8 +185,8 @@
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
- Handle<JSFunction> function = factory->NewFunctionWithPrototype(
- factory->function_string(), factory->null_value());
+ Handle<JSFunction> function = factory->NewFunction(
+ factory->function_string());
Handle<JSObject> key = factory->NewJSObject(function);
Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
@@ -225,8 +225,8 @@
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
- Handle<JSFunction> function = factory->NewFunctionWithPrototype(
- factory->function_string(), factory->null_value());
+ Handle<JSFunction> function = factory->NewFunction(
+ factory->function_string());
// 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 Fri Apr 25
13:06:21 2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-weaksets.cc Fri May 9
16:39:33 2014 UTC
@@ -185,8 +185,8 @@
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
- Handle<JSFunction> function = factory->NewFunctionWithPrototype(
- factory->function_string(), factory->null_value());
+ Handle<JSFunction> function = factory->NewFunction(
+ factory->function_string());
Handle<JSObject> key = factory->NewJSObject(function);
Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate);
@@ -225,8 +225,8 @@
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
- Handle<JSFunction> function = factory->NewFunctionWithPrototype(
- factory->function_string(), factory->null_value());
+ Handle<JSFunction> function = factory->NewFunction(
+ factory->function_string());
// 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.