Replace NewFunctionWithPrototype(name, prototype) by NewFunction(name)

BUG=
R=ishell@chromium.org

Review URL: https://codereview.chromium.org/268063008

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21235 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
verwaest@chromium.org 2014-05-09 16:39:33 +00:00
parent 8db908784e
commit a773cd7271
9 changed files with 36 additions and 64 deletions

View File

@ -461,8 +461,7 @@ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
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<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
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 @@ Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
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 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
{ // -- 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 @@ bool Genesis::InstallNatives() {
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.

View File

@ -1203,11 +1203,14 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
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::NewFunction(Handle<String> name,
}
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<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype,
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 ||

View File

@ -452,12 +452,9 @@ class Factory V8_FINAL {
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,

View File

@ -2806,13 +2806,8 @@ static Handle<JSFunction> InstallBuiltin(Isolate* isolate,
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;

View File

@ -137,8 +137,8 @@ TEST(StressJS) {
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);

View File

@ -261,11 +261,7 @@ TEST(GarbageCollection) {
{
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 @@ TEST(FunctionAllocation) {
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 @@ TEST(JSObjectMaps) {
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);

View File

@ -156,11 +156,7 @@ TEST(MarkCompactCollector) {
{ 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);

View File

@ -185,8 +185,8 @@ TEST(Regress2060a) {
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 @@ TEST(Regress2060b) {
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();

View File

@ -185,8 +185,8 @@ TEST(WeakSet_Regress2060a) {
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 @@ TEST(WeakSet_Regress2060b) {
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();