Chromium Code Reviews| Index: src/factory.cc |
| diff --git a/src/factory.cc b/src/factory.cc |
| index 2f188f57b3f99ac9a44f6c19b3a554235e3e9cb8..dd984492dad515e4155f811cfae76043c14c0096 100644 |
| --- a/src/factory.cc |
| +++ b/src/factory.cc |
| @@ -1202,38 +1202,48 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map, |
| } |
| -Handle<JSFunction> Factory::NewFunction(Handle<String> name, |
| - MaybeHandle<Code> maybe_code, |
| - MaybeHandle<Object> maybe_prototype) { |
| - Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name); |
| - ASSERT(info->strict_mode() == SLOPPY); |
| - Handle<Code> code; |
| - if (maybe_code.ToHandle(&code)) { |
| - info->set_code(*code); |
| - } |
| +Handle<JSFunction> Factory::NewFunction(Handle<Map> map, |
| + Handle<SharedFunctionInfo> info) { |
|
Igor Sheludko
2014/05/08 09:51:40
I think you could simplify constructors even more
|
| Handle<Context> context(isolate()->context()->native_context()); |
| - Handle<Map> map = maybe_prototype.is_null() |
| - ? isolate()->sloppy_function_without_prototype_map() |
| - : isolate()->sloppy_function_map(); |
| - Handle<JSFunction> result = NewFunction(map, info, context); |
| - Handle<Object> prototype; |
| - if (maybe_prototype.ToHandle(&prototype)) { |
| - result->set_prototype_or_initial_map(*prototype); |
| - } |
| - return result; |
| + return NewFunction(map, info, context); |
| } |
| Handle<JSFunction> Factory::NewFunction(Handle<String> name) { |
| - return NewFunction(name, MaybeHandle<Code>(), the_hole_value()); |
| + Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name); |
| + ASSERT(info->strict_mode() == SLOPPY); |
| + return NewFunction(isolate()->sloppy_function_map(), info); |
|
Igor Sheludko
2014/05/08 09:51:40
... then this would be just:
return NewFunction(Ne
|
| +} |
| + |
| + |
| +Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, |
| + Handle<Code> code) { |
| + Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name); |
| + info->set_code(*code); |
| + ASSERT(info->strict_mode() == SLOPPY); |
| + Handle<Map> map = isolate()->sloppy_function_without_prototype_map(); |
| + return NewFunction(map, info); |
|
Igor Sheludko
2014/05/08 09:51:40
... this method will look like:
return NewFunction
|
| } |
| -Handle<JSFunction> Factory::NewFunction(Handle<Object> prototype, |
| - Handle<String> name, |
| +Handle<JSFunction> Factory::NewFunction(Handle<String> name, |
| + Handle<Code> code, |
| + Handle<Object> prototype) { |
| + Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name); |
| + info->set_code(*code); |
| + ASSERT(info->strict_mode() == SLOPPY); |
| + Handle<Map> map = isolate()->sloppy_function_map(); |
| + Handle<JSFunction> result = NewFunction(map, info); |
|
Igor Sheludko
2014/05/08 09:51:40
... and this method will look like:
Handle<JSFunct
|
| + result->set_prototype_or_initial_map(*prototype); |
| + return result; |
| +} |
| + |
| + |
| +Handle<JSFunction> Factory::NewFunction(Handle<String> name, |
| + Handle<Code> code, |
| + Handle<Object> prototype, |
| InstanceType type, |
| - int instance_size, |
| - Handle<Code> code) { |
| + int instance_size) { |
| // Allocate the function |
| Handle<JSFunction> function = NewFunction(name, code, prototype); |
| @@ -1251,10 +1261,10 @@ Handle<JSFunction> Factory::NewFunction(Handle<Object> prototype, |
| Handle<JSFunction> Factory::NewFunction(Handle<String> name, |
| + Handle<Code> code, |
| InstanceType type, |
| - int instance_size, |
| - Handle<Code> code) { |
| - return NewFunction(the_hole_value(), name, type, instance_size, code); |
| + int instance_size) { |
| + return NewFunction(name, code, the_hole_value(), type, instance_size); |
| } |
| @@ -2085,9 +2095,9 @@ Handle<JSFunction> Factory::CreateApiFunction( |
| } |
| Handle<JSFunction> result = obj->remove_prototype() |
| - ? NewFunction(Factory::empty_string(), code) |
| - : NewFunction(prototype, Factory::empty_string(), |
| - type, instance_size, code); |
| + ? NewFunctionWithoutPrototype(Factory::empty_string(), code) |
| + : NewFunction(Factory::empty_string(), code, prototype, |
| + type, instance_size); |
| result->shared()->set_length(obj->length()); |
| Handle<Object> class_name(obj->class_name(), isolate()); |