Reviewers: Michael Starzinger,
Message:
PTAL
Description:
Generalize builtins inlining flag to allow forced inlining of any function
Please review this at https://codereview.chromium.org/1140743004/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+35, -33 lines):
M src/collection.js
M src/compiler/js-inlining.cc
M src/hydrogen.cc
M src/math.js
M src/objects.h
M src/objects-inl.h
M src/runtime/runtime.h
M src/runtime/runtime-function.cc
M src/third_party/fdlibm/fdlibm.js
M src/v8natives.js
M test/cctest/compiler/test-run-inlining.cc
Index: src/collection.js
diff --git a/src/collection.js b/src/collection.js
index
db30546165119e53f0c4e03a1b5e856259927f10..eddf0f32655f1ed0be27c2a496c2a803e09d4391
100644
--- a/src/collection.js
+++ b/src/collection.js
@@ -18,7 +18,7 @@ function HashToEntry(table, hash, numBuckets) {
var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets);
return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket);
}
-%SetInlineBuiltinFlag(HashToEntry);
+%SetForceInlineFlag(HashToEntry);
function SetFindEntry(table, numBuckets, key, hash) {
@@ -36,7 +36,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
}
return NOT_FOUND;
}
-%SetInlineBuiltinFlag(SetFindEntry);
+%SetForceInlineFlag(SetFindEntry);
function MapFindEntry(table, numBuckets, key, hash) {
@@ -54,7 +54,7 @@ function MapFindEntry(table, numBuckets, key, hash) {
}
return NOT_FOUND;
}
-%SetInlineBuiltinFlag(MapFindEntry);
+%SetForceInlineFlag(MapFindEntry);
function ComputeIntegerHash(key, seed) {
@@ -68,7 +68,7 @@ function ComputeIntegerHash(key, seed) {
hash = hash ^ (hash >>> 16);
return hash;
}
-%SetInlineBuiltinFlag(ComputeIntegerHash);
+%SetForceInlineFlag(ComputeIntegerHash);
function GetHash(key) {
@@ -83,7 +83,7 @@ function GetHash(key) {
}
return %GenericHash(key);
}
-%SetInlineBuiltinFlag(GetHash);
+%SetForceInlineFlag(GetHash);
// -------------------------------------------------------------------
Index: src/compiler/js-inlining.cc
diff --git a/src/compiler/js-inlining.cc b/src/compiler/js-inlining.cc
index
90c6eecb2e94688016ddeca3e213a4ff50b5b18d..0380cb68b2ff811dd7882e4f44550357d066d5cd
100644
--- a/src/compiler/js-inlining.cc
+++ b/src/compiler/js-inlining.cc
@@ -295,7 +295,7 @@ Reduction JSInliner::Reduce(Node* node) {
Handle<JSFunction> function = match.Value().handle();
if (!function->IsJSFunction()) return NoChange();
- if (mode_ == kBuiltinsInlining && !function->shared()->inline_builtin())
{
+ if (mode_ == kBuiltinsInlining && !function->shared()->force_inline()) {
return NoChange();
}
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
4f04580376789ec692104af8d6f914bc62b53634..1665c562d2c988cb8b0fab7534ad9764a33a0f87
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -7951,8 +7951,11 @@ int
HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) {
Handle<SharedFunctionInfo> target_shared(target->shared());
// Always inline builtins marked for inlining.
+ if (target_shared->force_inline()) {
+ return 0;
+ }
if (target->IsBuiltin()) {
- return target_shared->inline_builtin() ? 0 : kNotInlinable;
+ return kNotInlinable;
}
if (target_shared->IsApiFunction()) {
Index: src/math.js
diff --git a/src/math.js b/src/math.js
index
633a5d02c45d37ef830afbb221c8e5fc5138e08c..427e329812d2fe6244e47c5c75ddd9d12f06137b
100644
--- a/src/math.js
+++ b/src/math.js
@@ -344,18 +344,18 @@ $installFunctions(Math, DONT_ENUM, [
"cbrt", MathCbrt
]);
-%SetInlineBuiltinFlag(MathAbs);
-%SetInlineBuiltinFlag(MathAcosJS);
-%SetInlineBuiltinFlag(MathAsinJS);
-%SetInlineBuiltinFlag(MathAtanJS);
-%SetInlineBuiltinFlag(MathAtan2JS);
-%SetInlineBuiltinFlag(MathCeil);
-%SetInlineBuiltinFlag(MathClz32JS);
-%SetInlineBuiltinFlag(MathFloorJS);
-%SetInlineBuiltinFlag(MathRandom);
-%SetInlineBuiltinFlag(MathSign);
-%SetInlineBuiltinFlag(MathSqrtJS);
-%SetInlineBuiltinFlag(MathTrunc);
+%SetForceInlineFlag(MathAbs);
+%SetForceInlineFlag(MathAcosJS);
+%SetForceInlineFlag(MathAsinJS);
+%SetForceInlineFlag(MathAtanJS);
+%SetForceInlineFlag(MathAtan2JS);
+%SetForceInlineFlag(MathCeil);
+%SetForceInlineFlag(MathClz32JS);
+%SetForceInlineFlag(MathFloorJS);
+%SetForceInlineFlag(MathRandom);
+%SetForceInlineFlag(MathSign);
+%SetForceInlineFlag(MathSqrtJS);
+%SetForceInlineFlag(MathTrunc);
// Expose to the global scope.
$abs = MathAbs;
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
fbef269b3b2e8eb69f9c69c54d2da05c03da43fa..bf970ce7bd5f321135e8751ae0a05a8b1595e518
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -5785,8 +5785,7 @@ void SharedFunctionInfo::set_kind(FunctionKind kind) {
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, uses_super_property,
kUsesSuperProperty)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
-BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, inline_builtin,
- kInlineBuiltin)
+BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline,
kForceInline)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
name_should_print_as_anonymous,
kNameShouldPrintAsAnonymous)
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
9aec541d7e04b901cb0822e0dc872ed5d0012170..3ca4bb2496436e0dedbe7ace6348398c5d605394
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -7093,8 +7093,8 @@ class SharedFunctionInfo: public HeapObject {
// global object.
DECL_BOOLEAN_ACCESSORS(native)
- // Indicate that this builtin needs to be inlined in crankshaft.
- DECL_BOOLEAN_ACCESSORS(inline_builtin)
+ // Indicate that this function should always be inlined in optimized
code.
+ DECL_BOOLEAN_ACCESSORS(force_inline)
// Indicates that the function was created by the Function function.
// Though it's anonymous, toString should treat it as if it had the name
@@ -7372,7 +7372,7 @@ class SharedFunctionInfo: public HeapObject {
kUsesSuperProperty,
kHasDuplicateParameters,
kNative,
- kInlineBuiltin,
+ kForceInline,
kBoundFunction,
kIsAnonymous,
kNameShouldPrintAsAnonymous,
Index: src/runtime/runtime-function.cc
diff --git a/src/runtime/runtime-function.cc
b/src/runtime/runtime-function.cc
index
ade955c1a028655f10f76d249c193e9bd08b023f..7e7f50342fa56907a6c9c6905d034411bc40e085
100644
--- a/src/runtime/runtime-function.cc
+++ b/src/runtime/runtime-function.cc
@@ -311,14 +311,14 @@ RUNTIME_FUNCTION(Runtime_IsConstructor) {
}
-RUNTIME_FUNCTION(Runtime_SetInlineBuiltinFlag) {
+RUNTIME_FUNCTION(Runtime_SetForceInlineFlag) {
SealHandleScope shs(isolate);
RUNTIME_ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
if (object->IsJSFunction()) {
JSFunction* func = JSFunction::cast(*object);
- func->shared()->set_inline_builtin(true);
+ func->shared()->set_force_inline(true);
}
return isolate->heap()->undefined_value();
}
Index: src/runtime/runtime.h
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index
bd37a68a753aa8182469f5d8eb3f10ae6d064b7d..7b249afda812635948e9d6c90e41f35f15fb753d
100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -210,7 +210,7 @@ namespace internal {
F(SetNativeFlag, 1, 1) \
F(ThrowStrongModeTooFewArguments, 0, 1) \
F(IsConstructor, 1, 1) \
- F(SetInlineBuiltinFlag, 1, 1) \
+ F(SetForceInlineFlag, 1, 1) \
F(FunctionBindArguments, 4, 1) \
F(BoundFunctionGetBindings, 1, 1) \
F(NewObjectFromBound, 1, 1) \
Index: src/third_party/fdlibm/fdlibm.js
diff --git a/src/third_party/fdlibm/fdlibm.js
b/src/third_party/fdlibm/fdlibm.js
index
82f50cc514096ca1ab8ccfb031e0240703e40eb3..eabaa19fddd09f4829cd230814eb7014fb8b8c5b
100644
--- a/src/third_party/fdlibm/fdlibm.js
+++ b/src/third_party/fdlibm/fdlibm.js
@@ -1024,7 +1024,7 @@ $installFunctions(GlobalMath, DONT_ENUM, [
"expm1", MathExpm1
]);
-%SetInlineBuiltinFlag(MathSin);
-%SetInlineBuiltinFlag(MathCos);
+%SetForceInlineFlag(MathSin);
+%SetForceInlineFlag(MathCos);
})
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index
94133bff7fe05dfd496a1e42172bc679aca140aa..47094e29b9110da819e8b77a91aa091dad463668
100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1753,7 +1753,7 @@ InstallFunctions(GlobalNumber, DONT_ENUM, [
"parseFloat", GlobalParseFloat
]);
-%SetInlineBuiltinFlag(NumberIsNaN);
+%SetForceInlineFlag(NumberIsNaN);
//
----------------------------------------------------------------------------
Index: test/cctest/compiler/test-run-inlining.cc
diff --git a/test/cctest/compiler/test-run-inlining.cc
b/test/cctest/compiler/test-run-inlining.cc
index
61f3b62e89e49856f8ae4914178c4e764e2553d1..7dc6238d8bc6db5ea8098cf79154fda7a25b4092
100644
--- a/test/cctest/compiler/test-run-inlining.cc
+++ b/test/cctest/compiler/test-run-inlining.cc
@@ -499,7 +499,7 @@ TEST(InlineBuiltin) {
"(function () {"
" function foo(s,t,u) { AssertInlineCount(2); return true; }"
" function bar() { return foo(); };"
- " %SetInlineBuiltinFlag(foo);"
+ " %SetForceInlineFlag(foo);"
" return bar;"
"})();",
kBuiltinInlineFlags);
@@ -516,8 +516,8 @@ TEST(InlineNestedBuiltin) {
" function foo(s,t,u) { AssertInlineCount(3); return true; }"
" function baz(s,t,u) { return foo(s,t,u); }"
" function bar() { return baz(); };"
- " %SetInlineBuiltinFlag(foo);"
- " %SetInlineBuiltinFlag(baz);"
+ " %SetForceInlineFlag(foo);"
+ " %SetForceInlineFlag(baz);"
" return bar;"
"})();",
kBuiltinInlineFlags);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.