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 2099983004: Revert of Refactor CreateApiFunction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/factory.h ('k') | src/objects.h » ('j') | 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 "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 bool is_strict) { 1271 bool is_strict) {
1272 Handle<Map> map = is_strict 1272 Handle<Map> map = is_strict
1273 ? isolate()->strict_function_without_prototype_map() 1273 ? isolate()->strict_function_without_prototype_map()
1274 : isolate()->sloppy_function_without_prototype_map(); 1274 : isolate()->sloppy_function_without_prototype_map();
1275 return NewFunction(map, name, code); 1275 return NewFunction(map, name, code);
1276 } 1276 }
1277 1277
1278 1278
1279 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, 1279 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
1280 Handle<Object> prototype, 1280 Handle<Object> prototype,
1281 bool is_strict) {
1282 Handle<Map> map = is_strict ? isolate()->strict_function_map()
1283 : isolate()->sloppy_function_map();
1284 Handle<JSFunction> result = NewFunction(map, name, code);
1285 result->set_prototype_or_initial_map(*prototype);
1286 return result;
1287 }
1288
1289
1290 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
1291 Handle<Object> prototype,
1281 InstanceType type, int instance_size, 1292 InstanceType type, int instance_size,
1282 bool is_strict) { 1293 bool is_strict) {
1283 // Allocate the function 1294 // Allocate the function
1284 Handle<Map> map = is_strict ? isolate()->strict_function_map() 1295 Handle<JSFunction> function = NewFunction(name, code, prototype, is_strict);
1285 : isolate()->sloppy_function_map();
1286 Handle<JSFunction> function = NewFunction(map, name, code);
1287 DCHECK(prototype->IsTheHole(isolate()) || prototype->IsNull(isolate()) ||
1288 prototype->IsJSReceiver());
1289 function->set_prototype_or_initial_map(*prototype);
1290 1296
1291 // TODO(verwaest): Do we need to eagerly allocate the map here?
1292 ElementsKind elements_kind = 1297 ElementsKind elements_kind =
1293 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS; 1298 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS;
1294 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind); 1299 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind);
1295 prototype = JSFunction::GetPrototype(isolate(), function); 1300 // TODO(littledan): Why do we have this is_generator test when
1301 // NewFunctionPrototype already handles finding an appropriately
1302 // shared prototype?
1303 if (!function->shared()->is_resumable()) {
1304 if (prototype->IsTheHole(isolate())) {
1305 prototype = NewFunctionPrototype(function);
1306 }
1307 }
1308
1296 JSFunction::SetInitialMap(function, initial_map, 1309 JSFunction::SetInitialMap(function, initial_map,
1297 Handle<JSReceiver>::cast(prototype)); 1310 Handle<JSReceiver>::cast(prototype));
1298 1311
1299 return function; 1312 return function;
1300 } 1313 }
1301 1314
1302 1315
1303 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 1316 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
1304 Handle<Code> code, 1317 Handle<Code> code,
1305 InstanceType type, 1318 InstanceType type,
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 } 2379 }
2367 2380
2368 2381
2369 Handle<Object> Factory::ToBoolean(bool value) { 2382 Handle<Object> Factory::ToBoolean(bool value) {
2370 return value ? true_value() : false_value(); 2383 return value ? true_value() : false_value();
2371 } 2384 }
2372 2385
2373 2386
2374 } // namespace internal 2387 } // namespace internal
2375 } // namespace v8 2388 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698