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

Unified Diff: src/factory.cc

Issue 265763007: Merge NewFunction and NewFunctionWithPrototype (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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-debug.cc » ('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 9abb015d8066da1c66ac183e8ac57fe7904a2632..a8035d8a47ad819e0ce53a4df934c52db3a59bce 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1246,14 +1246,9 @@ Handle<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype,
type != JS_OBJECT_TYPE ||
instance_size != JSObject::kHeaderSize) {
Handle<Object> prototype = maybe_prototype.ToHandleChecked();
- Handle<Map> initial_map = NewMap(type, instance_size);
- if (prototype->IsJSObject()) {
- JSObject::SetLocalPropertyIgnoreAttributes(
- Handle<JSObject>::cast(prototype),
- constructor_string(),
- function,
- DONT_ENUM).Assert();
- } else if (!function->shared()->is_generator()) {
+ Handle<Map> initial_map = NewMap(
+ type, instance_size, GetInitialFastElementsKind());
+ if (prototype->IsTheHole() && !function->shared()->is_generator()) {
prototype = NewFunctionPrototype(function);
}
initial_map->set_prototype(*prototype);
@@ -1278,30 +1273,6 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name,
}
-Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
- InstanceType type,
- int instance_size,
- Handle<JSObject> prototype,
- Handle<Code> code,
- bool force_initial_map) {
- // Allocate the function.
- Handle<JSFunction> function = NewFunction(name, code, prototype);
-
- if (force_initial_map ||
- type != JS_OBJECT_TYPE ||
- instance_size != JSObject::kHeaderSize) {
- Handle<Map> initial_map = NewMap(type,
- instance_size,
- GetInitialFastElementsKind());
- function->set_initial_map(*initial_map);
- initial_map->set_constructor(*function);
- }
-
- JSFunction::SetPrototype(function, prototype);
- return function;
-}
-
-
Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
// Make sure to use globals from the function's context, since the function
// can be from a different context.
@@ -2151,6 +2122,13 @@ Handle<JSFunction> Factory::CreateApiFunction(
ASSERT(!result->has_prototype());
return result;
}
+
+ JSObject::SetLocalPropertyIgnoreAttributes(
+ handle(JSObject::cast(result->prototype())),
+ constructor_string(),
+ result,
+ DONT_ENUM).Assert();
+
// Down from here is only valid for API functions that can be used as a
// constructor (don't set the "remove prototype" flag).
« no previous file with comments | « src/factory.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698