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

Unified Diff: src/factory.cc

Issue 261983007: Only force creating initial maps when we have prototypes. (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 | « no previous file | no next file » | 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 bf0e7d0382b1d03265108bfb13dc492d9dafb363..af1e2a4a7c0351c35d3f2b5e496b55560ee91486 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1240,11 +1240,10 @@ Handle<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype,
// Allocate the function
Handle<JSFunction> function = NewFunction(name, code, maybe_prototype);
- Handle<Object> prototype;
- if (maybe_prototype.ToHandle(&prototype) &&
- (force_initial_map ||
- type != JS_OBJECT_TYPE ||
- instance_size != JSObject::kHeaderSize)) {
+ if (force_initial_map ||
+ 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(
@@ -2133,7 +2132,7 @@ Handle<JSFunction> Factory::CreateApiFunction(
Handle<JSFunction> result = NewFunction(
maybe_prototype, Factory::empty_string(), type,
- instance_size, code, true);
+ instance_size, code, !obj->remove_prototype());
result->shared()->set_length(obj->length());
Handle<Object> class_name(obj->class_name(), isolate());
@@ -2147,6 +2146,8 @@ Handle<JSFunction> Factory::CreateApiFunction(
if (obj->remove_prototype()) {
ASSERT(result->shared()->IsApiFunction());
+ ASSERT(!result->has_initial_map());
+ ASSERT(!result->has_prototype());
return result;
}
// Down from here is only valid for API functions that can be used as a
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698