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

Side by Side Diff: src/bootstrapper.cc

Issue 918303005: Avoid repeating code when creating builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 | « 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 "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 Isolate* isolate = holder->GetIsolate(); 2260 Isolate* isolate = holder->GetIsolate();
2261 Handle<Object> function_object = 2261 Handle<Object> function_object =
2262 Object::GetProperty(isolate, holder, function_name).ToHandleChecked(); 2262 Object::GetProperty(isolate, holder, function_name).ToHandleChecked();
2263 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 2263 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
2264 function->shared()->set_function_data(Smi::FromInt(id)); 2264 function->shared()->set_function_data(Smi::FromInt(id));
2265 } 2265 }
2266 2266
2267 2267
2268 void Genesis::InstallBuiltinFunctionIds() { 2268 void Genesis::InstallBuiltinFunctionIds() {
2269 HandleScope scope(isolate()); 2269 HandleScope scope(isolate());
2270 struct BuiltinFunctionIds {
2271 const char* holder_expr;
2272 const char* fun_name;
2273 BuiltinFunctionId id;
2274 };
2275
2270 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ 2276 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
2271 { \ 2277 { #holder_expr, #fun_name, k##name } \
2272 Handle<JSObject> holder = ResolveBuiltinIdHolder( \ 2278 ,
2273 native_context(), #holder_expr); \ 2279 const BuiltinFunctionIds builtins[] = {
2274 BuiltinFunctionId id = k##name; \ 2280 FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)};
2275 InstallBuiltinFunctionId(holder, #fun_name, id); \ 2281 #undef INSTALL_BUILTIN_ID
2282
2283 for (const BuiltinFunctionIds& builtin : builtins) {
2284 Handle<JSObject> holder =
2285 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr);
2286 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id);
2276 } 2287 }
2277 FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)
2278 #undef INSTALL_BUILTIN_ID
2279 } 2288 }
2280 2289
2281 2290
2282 // Do not forget to update macros.py with named constant 2291 // Do not forget to update macros.py with named constant
2283 // of cache id. 2292 // of cache id.
2284 #define JSFUNCTION_RESULT_CACHE_LIST(F) \ 2293 #define JSFUNCTION_RESULT_CACHE_LIST(F) \
2285 F(16, native_context()->regexp_function()) 2294 F(16, native_context()->regexp_function())
2286 2295
2287 2296
2288 static FixedArray* CreateCache(int size, Handle<JSFunction> factory_function) { 2297 static FixedArray* CreateCache(int size, Handle<JSFunction> factory_function) {
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 return from + sizeof(NestingCounterType); 2868 return from + sizeof(NestingCounterType);
2860 } 2869 }
2861 2870
2862 2871
2863 // Called when the top-level V8 mutex is destroyed. 2872 // Called when the top-level V8 mutex is destroyed.
2864 void Bootstrapper::FreeThreadResources() { 2873 void Bootstrapper::FreeThreadResources() {
2865 DCHECK(!IsActive()); 2874 DCHECK(!IsActive());
2866 } 2875 }
2867 2876
2868 } } // namespace v8::internal 2877 } } // 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