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

Unified Diff: src/factory.cc

Issue 264973020: Replace NewFunction(MaybeHandle<> prototype by Handle<> prototype (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/runtime.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 27c6f6dc2f67707d3497dbbf3fedc0c139f309ee..2f188f57b3f99ac9a44f6c19b3a554235e3e9cb8 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1203,8 +1203,8 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
Handle<JSFunction> Factory::NewFunction(Handle<String> name,
- MaybeHandle<Object> maybe_prototype,
- MaybeHandle<Code> maybe_code) {
+ MaybeHandle<Code> maybe_code,
+ MaybeHandle<Object> maybe_prototype) {
Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
ASSERT(info->strict_mode() == SLOPPY);
Handle<Code> code;
@@ -1225,34 +1225,26 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name,
Handle<JSFunction> Factory::NewFunction(Handle<String> name) {
- return NewFunction(name, the_hole_value(), MaybeHandle<Code>());
+ return NewFunction(name, MaybeHandle<Code>(), the_hole_value());
}
-Handle<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype,
+Handle<JSFunction> Factory::NewFunction(Handle<Object> prototype,
Handle<String> name,
InstanceType type,
int instance_size,
Handle<Code> code) {
// Allocate the function
- Handle<JSFunction> function = NewFunction(name, maybe_prototype, code);
-
- if (!maybe_prototype.is_null() ||
- type != JS_OBJECT_TYPE ||
- instance_size != JSObject::kHeaderSize) {
- Handle<Object> prototype = maybe_prototype.ToHandleChecked();
- Handle<Map> initial_map = NewMap(
- type, instance_size, GetInitialFastElementsKind());
- if (prototype->IsTheHole() && !function->shared()->is_generator()) {
- prototype = NewFunctionPrototype(function);
- }
- initial_map->set_prototype(*prototype);
- function->set_initial_map(*initial_map);
- initial_map->set_constructor(*function);
- } else {
- ASSERT(!function->has_initial_map());
- ASSERT(!function->has_prototype());
+ Handle<JSFunction> function = NewFunction(name, code, prototype);
+
+ Handle<Map> initial_map = NewMap(
+ type, instance_size, GetInitialFastElementsKind());
+ if (prototype->IsTheHole() && !function->shared()->is_generator()) {
+ prototype = NewFunctionPrototype(function);
}
+ initial_map->set_prototype(*prototype);
+ function->set_initial_map(*initial_map);
+ initial_map->set_constructor(*function);
return function;
}
@@ -2092,11 +2084,10 @@ Handle<JSFunction> Factory::CreateApiFunction(
break;
}
- MaybeHandle<Object> maybe_prototype = prototype;
- if (obj->remove_prototype()) maybe_prototype = MaybeHandle<Object>();
-
- Handle<JSFunction> result = NewFunction(
- maybe_prototype, Factory::empty_string(), type, instance_size, code);
+ Handle<JSFunction> result = obj->remove_prototype()
+ ? NewFunction(Factory::empty_string(), code)
Igor Sheludko 2014/05/07 19:01:51 I think you can omit Function:: here and the line
+ : NewFunction(prototype, Factory::empty_string(),
+ type, instance_size, code);
result->shared()->set_length(obj->length());
Handle<Object> class_name(obj->class_name(), isolate());
« no previous file with comments | « src/factory.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698