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

Side by Side Diff: src/factory.cc

Issue 352813002: Wrap InitializeProperty around SetOwnPropertyIgnoreAttributes and switch over uses (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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
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 "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/conversions.h" 7 #include "src/conversions.h"
8 #include "src/isolate-inl.h" 8 #include "src/isolate-inl.h"
9 #include "src/macro-assembler.h" 9 #include "src/macro-assembler.h"
10 10
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 // Each function prototype gets a fresh map to avoid unwanted sharing of 1326 // Each function prototype gets a fresh map to avoid unwanted sharing of
1327 // maps between prototypes of different constructors. 1327 // maps between prototypes of different constructors.
1328 Handle<JSFunction> object_function(native_context->object_function()); 1328 Handle<JSFunction> object_function(native_context->object_function());
1329 ASSERT(object_function->has_initial_map()); 1329 ASSERT(object_function->has_initial_map());
1330 new_map = Map::Copy(handle(object_function->initial_map())); 1330 new_map = Map::Copy(handle(object_function->initial_map()));
1331 } 1331 }
1332 1332
1333 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); 1333 Handle<JSObject> prototype = NewJSObjectFromMap(new_map);
1334 1334
1335 if (!function->shared()->is_generator()) { 1335 if (!function->shared()->is_generator()) {
1336 JSObject::SetOwnPropertyIgnoreAttributes(prototype, 1336 JSObject::InitializeProperty(prototype, constructor_string(),
1337 constructor_string(), 1337 function, DONT_ENUM);
1338 function,
1339 DONT_ENUM).Assert();
1340 } 1338 }
1341 1339
1342 return prototype; 1340 return prototype;
1343 } 1341 }
1344 1342
1345 1343
1346 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 1344 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1347 Handle<SharedFunctionInfo> info, 1345 Handle<SharedFunctionInfo> info,
1348 Handle<Context> context, 1346 Handle<Context> context,
1349 PretenureFlag pretenure) { 1347 PretenureFlag pretenure) {
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 result->shared()->set_construct_stub(*construct_stub); 2161 result->shared()->set_construct_stub(*construct_stub);
2164 result->shared()->DontAdaptArguments(); 2162 result->shared()->DontAdaptArguments();
2165 2163
2166 if (obj->remove_prototype()) { 2164 if (obj->remove_prototype()) {
2167 ASSERT(result->shared()->IsApiFunction()); 2165 ASSERT(result->shared()->IsApiFunction());
2168 ASSERT(!result->has_initial_map()); 2166 ASSERT(!result->has_initial_map());
2169 ASSERT(!result->has_prototype()); 2167 ASSERT(!result->has_prototype());
2170 return result; 2168 return result;
2171 } 2169 }
2172 2170
2173 JSObject::SetOwnPropertyIgnoreAttributes( 2171 if (prototype->IsTheHole()) {
2174 handle(JSObject::cast(result->prototype())), 2172 #ifdef DEBUG
2175 constructor_string(), 2173 LookupIterator it(handle(JSObject::cast(result->prototype())),
2176 result, 2174 constructor_string(),
2177 DONT_ENUM).Assert(); 2175 LookupIterator::CHECK_OWN_REAL);
2176 MaybeHandle<Object> maybe_prop = Object::GetProperty(&it);
2177 ASSERT(it.IsFound());
2178 ASSERT(maybe_prop.ToHandleChecked().is_identical_to(result));
2179 #endif
2180 } else {
2181 JSObject::InitializeProperty(handle(JSObject::cast(result->prototype())),
2182 constructor_string(), result, DONT_ENUM);
2183 }
2178 2184
2179 // Down from here is only valid for API functions that can be used as a 2185 // Down from here is only valid for API functions that can be used as a
2180 // constructor (don't set the "remove prototype" flag). 2186 // constructor (don't set the "remove prototype" flag).
2181 2187
2182 Handle<Map> map(result->initial_map()); 2188 Handle<Map> map(result->initial_map());
2183 2189
2184 // Mark as undetectable if needed. 2190 // Mark as undetectable if needed.
2185 if (obj->undetectable()) { 2191 if (obj->undetectable()) {
2186 map->set_is_undetectable(); 2192 map->set_is_undetectable();
2187 } 2193 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 return Handle<Object>::null(); 2377 return Handle<Object>::null();
2372 } 2378 }
2373 2379
2374 2380
2375 Handle<Object> Factory::ToBoolean(bool value) { 2381 Handle<Object> Factory::ToBoolean(bool value) {
2376 return value ? true_value() : false_value(); 2382 return value ? true_value() : false_value();
2377 } 2383 }
2378 2384
2379 2385
2380 } } // namespace v8::internal 2386 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698