Reduce binary size of Builtins::CallableFor

by pulling parameterizable things out of the case-blocks.
No change in functionality.

BUG=chromium:714894

Review-Url: https://codereview.chromium.org/2854273004
Cr-Commit-Position: refs/heads/master@{#45066}
This commit is contained in:
jkummerow 2017-05-03 08:02:14 -07:00 committed by Commit bot
parent 192984ea88
commit 133ef93afa
2 changed files with 12 additions and 6 deletions

View File

@ -133,24 +133,29 @@ int Builtins::GetBuiltinParameterCount(Name name) {
// static
Callable Builtins::CallableFor(Isolate* isolate, Name name) {
Handle<Code> code(
reinterpret_cast<Code**>(isolate->builtins()->builtin_address(name)));
CallDescriptors::Key key;
switch (name) {
#define CASE(Name, ...) \
case k##Name: { \
Handle<Code> code = isolate->builtins()->Name(); \
auto descriptor = Builtin_##Name##_InterfaceDescriptor(isolate); \
return Callable(code, descriptor); \
// This macro is deliberately crafted so as to emit very little code,
// in order to keep binary size of this function under control.
#define CASE(Name, ...) \
case k##Name: { \
key = Builtin_##Name##_InterfaceDescriptor::key(); \
break; \
}
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE,
CASE, IGNORE_BUILTIN, IGNORE_BUILTIN)
#undef CASE
case kConsoleAssert: {
Handle<Code> code = isolate->builtins()->ConsoleAssert();
return Callable(code, BuiltinDescriptor(isolate));
}
default:
UNREACHABLE();
return Callable(Handle<Code>::null(), VoidDescriptor(isolate));
}
CallInterfaceDescriptor descriptor(isolate, key);
return Callable(code, descriptor);
}
// static

View File

@ -885,6 +885,7 @@ class WasmRuntimeCallDescriptor final : public CallInterfaceDescriptor {
BUILTIN_LIST_TFS(DEFINE_TFS_BUILTIN_DESCRIPTOR)
#undef DEFINE_TFS_BUILTIN_DESCRIPTOR
#undef DECLARE_DEFAULT_DESCRIPTOR
#undef DECLARE_DESCRIPTOR_WITH_BASE
#undef DECLARE_DESCRIPTOR
#undef DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE