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

Side by Side Diff: src/factory.cc

Issue 268063008: Replace NewFunctionWithPrototype(name, prototype) by NewFunction(name) (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 | « src/factory.h ('k') | src/runtime.cc » ('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 "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 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 Handle<Context> context, 1196 Handle<Context> context,
1197 PretenureFlag pretenure) { 1197 PretenureFlag pretenure) {
1198 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE; 1198 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE;
1199 Handle<JSFunction> result = New<JSFunction>(map, space); 1199 Handle<JSFunction> result = New<JSFunction>(map, space);
1200 InitializeFunction(result, info, context); 1200 InitializeFunction(result, info, context);
1201 return result; 1201 return result;
1202 } 1202 }
1203 1203
1204 1204
1205 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 1205 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
1206 Handle<Code> code, 1206 MaybeHandle<Object> maybe_prototype,
1207 MaybeHandle<Object> maybe_prototype) { 1207 MaybeHandle<Code> maybe_code) {
1208 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name); 1208 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
1209 ASSERT(info->strict_mode() == SLOPPY); 1209 ASSERT(info->strict_mode() == SLOPPY);
1210 info->set_code(*code); 1210 Handle<Code> code;
1211 if (maybe_code.ToHandle(&code)) {
1212 info->set_code(*code);
1213 }
1211 Handle<Context> context(isolate()->context()->native_context()); 1214 Handle<Context> context(isolate()->context()->native_context());
1212 Handle<Map> map = maybe_prototype.is_null() 1215 Handle<Map> map = maybe_prototype.is_null()
1213 ? isolate()->sloppy_function_without_prototype_map() 1216 ? isolate()->sloppy_function_without_prototype_map()
1214 : isolate()->sloppy_function_map(); 1217 : isolate()->sloppy_function_map();
1215 Handle<JSFunction> result = NewFunction(map, info, context); 1218 Handle<JSFunction> result = NewFunction(map, info, context);
1216 Handle<Object> prototype; 1219 Handle<Object> prototype;
1217 if (maybe_prototype.ToHandle(&prototype)) { 1220 if (maybe_prototype.ToHandle(&prototype)) {
1218 result->set_prototype_or_initial_map(*prototype); 1221 result->set_prototype_or_initial_map(*prototype);
1219 } 1222 }
1220 return result; 1223 return result;
1221 } 1224 }
1222 1225
1223 1226
1224 Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name, 1227 Handle<JSFunction> Factory::NewFunction(Handle<String> name) {
1225 Handle<Object> prototype) { 1228 return NewFunction(name, the_hole_value(), MaybeHandle<Code>());
1226 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
1227 ASSERT(info->strict_mode() == SLOPPY);
1228 Handle<Context> context(isolate()->context()->native_context());
1229 Handle<Map> map = isolate()->sloppy_function_map();
1230 Handle<JSFunction> result = NewFunction(map, info, context);
1231 result->set_prototype_or_initial_map(*prototype);
1232 return result;
1233 } 1229 }
1234 1230
1235 1231
1236 Handle<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype, 1232 Handle<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype,
1237 Handle<String> name, 1233 Handle<String> name,
1238 InstanceType type, 1234 InstanceType type,
1239 int instance_size, 1235 int instance_size,
1240 Handle<Code> code, 1236 Handle<Code> code,
1241 bool force_initial_map) { 1237 bool force_initial_map) {
1242 // Allocate the function 1238 // Allocate the function
1243 Handle<JSFunction> function = NewFunction(name, code, maybe_prototype); 1239 Handle<JSFunction> function = NewFunction(name, maybe_prototype, code);
1244 1240
1245 if (force_initial_map || 1241 if (force_initial_map ||
1246 type != JS_OBJECT_TYPE || 1242 type != JS_OBJECT_TYPE ||
1247 instance_size != JSObject::kHeaderSize) { 1243 instance_size != JSObject::kHeaderSize) {
1248 Handle<Object> prototype = maybe_prototype.ToHandleChecked(); 1244 Handle<Object> prototype = maybe_prototype.ToHandleChecked();
1249 Handle<Map> initial_map = NewMap( 1245 Handle<Map> initial_map = NewMap(
1250 type, instance_size, GetInitialFastElementsKind()); 1246 type, instance_size, GetInitialFastElementsKind());
1251 if (prototype->IsTheHole() && !function->shared()->is_generator()) { 1247 if (prototype->IsTheHole() && !function->shared()->is_generator()) {
1252 prototype = NewFunctionPrototype(function); 1248 prototype = NewFunctionPrototype(function);
1253 } 1249 }
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 return Handle<Object>::null(); 2320 return Handle<Object>::null();
2325 } 2321 }
2326 2322
2327 2323
2328 Handle<Object> Factory::ToBoolean(bool value) { 2324 Handle<Object> Factory::ToBoolean(bool value) {
2329 return value ? true_value() : false_value(); 2325 return value ? true_value() : false_value();
2330 } 2326 }
2331 2327
2332 2328
2333 } } // namespace v8::internal 2329 } } // namespace v8::internal
OLDNEW
« 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