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

Side by Side Diff: src/factory.cc

Issue 239053007: Always pass in code to NewFunctionWithoutPrototype (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment Created 6 years, 8 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') | 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 "macro-assembler.h" 7 #include "macro-assembler.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "v8conversions.h" 9 #include "v8conversions.h"
10 10
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 GetInitialFastElementsKind()); 1297 GetInitialFastElementsKind());
1298 function->set_initial_map(*initial_map); 1298 function->set_initial_map(*initial_map);
1299 initial_map->set_constructor(*function); 1299 initial_map->set_constructor(*function);
1300 } 1300 }
1301 1301
1302 JSFunction::SetPrototype(function, prototype); 1302 JSFunction::SetPrototype(function, prototype);
1303 return function; 1303 return function;
1304 } 1304 }
1305 1305
1306 1306
1307 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name,
1308 Handle<Code> code) {
1309 Handle<JSFunction> function = NewFunctionWithoutPrototype(name, SLOPPY);
1310 function->shared()->set_code(*code);
1311 function->set_code(*code);
1312 ASSERT(!function->has_initial_map());
1313 ASSERT(!function->has_prototype());
1314 return function;
1315 }
1316
1317
1318 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { 1307 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
1319 Handle<FixedArray> array = NewFixedArray(length, TENURED); 1308 Handle<FixedArray> array = NewFixedArray(length, TENURED);
1320 array->set_map_no_write_barrier(*scope_info_map()); 1309 array->set_map_no_write_barrier(*scope_info_map());
1321 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); 1310 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array);
1322 return scope_info; 1311 return scope_info;
1323 } 1312 }
1324 1313
1325 1314
1326 Handle<JSObject> Factory::NewExternal(void* value) { 1315 Handle<JSObject> Factory::NewExternal(void* value) {
1327 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value)); 1316 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value));
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 2007
2019 2008
2020 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 2009 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
2021 Handle<Object> prototype) { 2010 Handle<Object> prototype) {
2022 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name); 2011 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
2023 Handle<Context> context(isolate()->context()->native_context()); 2012 Handle<Context> context(isolate()->context()->native_context());
2024 return NewFunction(info, context, prototype); 2013 return NewFunction(info, context, prototype);
2025 } 2014 }
2026 2015
2027 2016
2028 Handle<JSFunction> Factory::NewFunctionWithoutPrototype( 2017 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name,
2029 Handle<String> name, 2018 Handle<Code> code) {
2030 StrictMode strict_mode) {
2031 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name); 2019 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
2020 info->set_code(*code);
2032 Handle<Context> context(isolate()->context()->native_context()); 2021 Handle<Context> context(isolate()->context()->native_context());
2033 Handle<JSFunction> fun = NewFunction(info, context, MaybeHandle<Object>()); 2022 return NewFunction(info, context, MaybeHandle<Object>());
2034 return fun;
2035 } 2023 }
2036 2024
2037 2025
2038 #ifdef ENABLE_DEBUGGER_SUPPORT 2026 #ifdef ENABLE_DEBUGGER_SUPPORT
2039 Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) { 2027 Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) {
2040 // Get the original code of the function. 2028 // Get the original code of the function.
2041 Handle<Code> code(shared->code()); 2029 Handle<Code> code(shared->code());
2042 2030
2043 // Create a copy of the code before allocating the debug info object to avoid 2031 // Create a copy of the code before allocating the debug info object to avoid
2044 // allocation while setting up the debug info object. 2032 // allocation while setting up the debug info object.
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 if (String::Equals(name, infinity_string())) return infinity_value(); 2317 if (String::Equals(name, infinity_string())) return infinity_value();
2330 return Handle<Object>::null(); 2318 return Handle<Object>::null();
2331 } 2319 }
2332 2320
2333 2321
2334 Handle<Object> Factory::ToBoolean(bool value) { 2322 Handle<Object> Factory::ToBoolean(bool value) {
2335 return value ? true_value() : false_value(); 2323 return value ? true_value() : false_value();
2336 } 2324 }
2337 2325
2338 } } // namespace v8::internal 2326 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698