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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "factory.h" 5 #include "factory.h"
6 6
7 #include "conversions.h" 7 #include "conversions.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "macro-assembler.h" 9 #include "macro-assembler.h"
10 10
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 1233
1234 Handle<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype, 1234 Handle<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype,
1235 Handle<String> name, 1235 Handle<String> name,
1236 InstanceType type, 1236 InstanceType type,
1237 int instance_size, 1237 int instance_size,
1238 Handle<Code> code, 1238 Handle<Code> code,
1239 bool force_initial_map) { 1239 bool force_initial_map) {
1240 // Allocate the function 1240 // Allocate the function
1241 Handle<JSFunction> function = NewFunction(name, code, maybe_prototype); 1241 Handle<JSFunction> function = NewFunction(name, code, maybe_prototype);
1242 1242
1243 Handle<Object> prototype; 1243 if (force_initial_map ||
1244 if (maybe_prototype.ToHandle(&prototype) && 1244 type != JS_OBJECT_TYPE ||
1245 (force_initial_map || 1245 instance_size != JSObject::kHeaderSize) {
1246 type != JS_OBJECT_TYPE || 1246 Handle<Object> prototype = maybe_prototype.ToHandleChecked();
1247 instance_size != JSObject::kHeaderSize)) {
1248 Handle<Map> initial_map = NewMap(type, instance_size); 1247 Handle<Map> initial_map = NewMap(type, instance_size);
1249 if (prototype->IsJSObject()) { 1248 if (prototype->IsJSObject()) {
1250 JSObject::SetLocalPropertyIgnoreAttributes( 1249 JSObject::SetLocalPropertyIgnoreAttributes(
1251 Handle<JSObject>::cast(prototype), 1250 Handle<JSObject>::cast(prototype),
1252 constructor_string(), 1251 constructor_string(),
1253 function, 1252 function,
1254 DONT_ENUM).Assert(); 1253 DONT_ENUM).Assert();
1255 } else if (!function->shared()->is_generator()) { 1254 } else if (!function->shared()->is_generator()) {
1256 prototype = NewFunctionPrototype(function); 1255 prototype = NewFunctionPrototype(function);
1257 } 1256 }
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 UNREACHABLE(); 2125 UNREACHABLE();
2127 type = JS_OBJECT_TYPE; // Keep the compiler happy. 2126 type = JS_OBJECT_TYPE; // Keep the compiler happy.
2128 break; 2127 break;
2129 } 2128 }
2130 2129
2131 MaybeHandle<Object> maybe_prototype = prototype; 2130 MaybeHandle<Object> maybe_prototype = prototype;
2132 if (obj->remove_prototype()) maybe_prototype = MaybeHandle<Object>(); 2131 if (obj->remove_prototype()) maybe_prototype = MaybeHandle<Object>();
2133 2132
2134 Handle<JSFunction> result = NewFunction( 2133 Handle<JSFunction> result = NewFunction(
2135 maybe_prototype, Factory::empty_string(), type, 2134 maybe_prototype, Factory::empty_string(), type,
2136 instance_size, code, true); 2135 instance_size, code, !obj->remove_prototype());
2137 2136
2138 result->shared()->set_length(obj->length()); 2137 result->shared()->set_length(obj->length());
2139 Handle<Object> class_name(obj->class_name(), isolate()); 2138 Handle<Object> class_name(obj->class_name(), isolate());
2140 if (class_name->IsString()) { 2139 if (class_name->IsString()) {
2141 result->shared()->set_instance_class_name(*class_name); 2140 result->shared()->set_instance_class_name(*class_name);
2142 result->shared()->set_name(*class_name); 2141 result->shared()->set_name(*class_name);
2143 } 2142 }
2144 result->shared()->set_function_data(*obj); 2143 result->shared()->set_function_data(*obj);
2145 result->shared()->set_construct_stub(*construct_stub); 2144 result->shared()->set_construct_stub(*construct_stub);
2146 result->shared()->DontAdaptArguments(); 2145 result->shared()->DontAdaptArguments();
2147 2146
2148 if (obj->remove_prototype()) { 2147 if (obj->remove_prototype()) {
2149 ASSERT(result->shared()->IsApiFunction()); 2148 ASSERT(result->shared()->IsApiFunction());
2149 ASSERT(!result->has_initial_map());
2150 ASSERT(!result->has_prototype());
2150 return result; 2151 return result;
2151 } 2152 }
2152 // Down from here is only valid for API functions that can be used as a 2153 // Down from here is only valid for API functions that can be used as a
2153 // constructor (don't set the "remove prototype" flag). 2154 // constructor (don't set the "remove prototype" flag).
2154 2155
2155 Handle<Map> map(result->initial_map()); 2156 Handle<Map> map(result->initial_map());
2156 2157
2157 // Mark as undetectable if needed. 2158 // Mark as undetectable if needed.
2158 if (obj->undetectable()) { 2159 if (obj->undetectable()) {
2159 map->set_is_undetectable(); 2160 map->set_is_undetectable();
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 return Handle<Object>::null(); 2345 return Handle<Object>::null();
2345 } 2346 }
2346 2347
2347 2348
2348 Handle<Object> Factory::ToBoolean(bool value) { 2349 Handle<Object> Factory::ToBoolean(bool value) {
2349 return value ? true_value() : false_value(); 2350 return value ? true_value() : false_value();
2350 } 2351 }
2351 2352
2352 2353
2353 } } // namespace v8::internal 2354 } } // namespace v8::internal
OLDNEW
« 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