Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: src/factory.cc

Issue 2095953002: Refactor CreateApiFunction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Create the template instantiation cache early enough Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index e197494e6b56176b101af20f5cbb48e0c1da39fd..09c4ec3789e77f773658e76dcb8ff238d354fc35 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1278,34 +1278,21 @@ Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name,
Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
Handle<Object> prototype,
- bool is_strict) {
- Handle<Map> map = is_strict ? isolate()->strict_function_map()
- : isolate()->sloppy_function_map();
- Handle<JSFunction> result = NewFunction(map, name, code);
- 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,
bool is_strict) {
// Allocate the function
- Handle<JSFunction> function = NewFunction(name, code, prototype, is_strict);
+ Handle<Map> map = is_strict ? isolate()->strict_function_map()
+ : isolate()->sloppy_function_map();
+ Handle<JSFunction> function = NewFunction(map, name, code);
+ DCHECK(prototype->IsTheHole(isolate()) || prototype->IsNull(isolate()) ||
+ prototype->IsJSReceiver());
+ function->set_prototype_or_initial_map(*prototype);
+ // TODO(verwaest): Do we need to eagerly allocate the map here?
ElementsKind elements_kind =
type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS;
Handle<Map> initial_map = NewMap(type, instance_size, elements_kind);
- // TODO(littledan): Why do we have this is_generator test when
- // NewFunctionPrototype already handles finding an appropriately
- // shared prototype?
- if (!function->shared()->is_resumable()) {
- if (prototype->IsTheHole(isolate())) {
- prototype = NewFunctionPrototype(function);
- }
- }
-
+ prototype = JSFunction::GetPrototype(isolate(), function);
JSFunction::SetInitialMap(function, initial_map,
Handle<JSReceiver>::cast(prototype));
« no previous file with comments | « src/factory.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698