Commit 3e0aabb6 authored by franzih's avatar franzih Committed by Commit bot

[runtime] Add function for printing type profile.

Separate the function that prints type profile with
--type-profile from the one that collects type profile.

The name needs to be stored in the feedback vector as well. I'll make a
follow up CL that stores the relevant information, so it can
be printed later.

BUG=v8:5935
R=yangguo@chromium.org

Review-Url: https://codereview.chromium.org/2757993002
Cr-Commit-Position: refs/heads/master@{#43929}
parent ab97fd76
......@@ -710,10 +710,6 @@ RUNTIME_FUNCTION(Runtime_CollectTypeProfile) {
CollectTypeProfileNexus nexus(vector, vector->ToSlot(index));
nexus.Collect(type);
PrintF("%s\n", name->ToCString().get());
nexus.Print();
PrintF("\n");
return *name;
}
......
......@@ -156,6 +156,35 @@ RUNTIME_FUNCTION(Runtime_IsConcurrentRecompilationSupported) {
isolate->concurrent_recompilation_enabled());
}
RUNTIME_FUNCTION(Runtime_PrintTypeProfile) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
if (!FLAG_type_profile) {
return isolate->heap()->undefined_value();
}
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
if (function->has_feedback_vector()) {
FeedbackVector* vector = function->feedback_vector();
Object* function_name = vector->shared_function_info()->name();
PrintF("Function: %s\n", String::cast(function_name)->ToCString().get());
FeedbackMetadataIterator iter(vector->metadata());
while (iter.HasNext()) {
FeedbackSlot slot = iter.Next();
FeedbackSlotKind kind = iter.kind();
if (kind == FeedbackSlotKind::kTypeProfile) {
CollectTypeProfileNexus nexus(vector, slot);
nexus.Print();
PrintF("\n");
return isolate->heap()->undefined_value();
}
}
}
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
HandleScope scope(isolate);
......
......@@ -551,6 +551,7 @@ namespace internal {
F(RunningInSimulator, 0, 1) \
F(IsConcurrentRecompilationSupported, 0, 1) \
F(OptimizeFunctionOnNextCall, -1, 1) \
F(PrintTypeProfile, 1, 1) \
F(InterpretFunctionOnNextCall, 1, 1) \
F(BaselineFunctionOnNextCall, 1, 1) \
F(OptimizeOsr, -1, 1) \
......
......@@ -2,22 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --type-profile --turbo
// Flags: --type-profile --turbo --allow-natives-syntax
function test(param) {
var my_var1 = param;
var my_var2 = 17;
}
%PrintTypeProfile(test);
test({});
test(123);
test('hello');
test(123);
%PrintTypeProfile(test);
test(undefined);
test('hello');
test({x: 12});
test({x: 12});
%PrintTypeProfile(test);
class MyClass {
constructor() {}
}
......
my_var1
Object
my_var2
number
my_var1
Object
number
my_var2
number
number
my_var1
Object
number
string
my_var2
number
number
number
my_var1
Object
number
string
number
my_var2
number
number
number
number
my_var1
Function: test
Object
number
string
number
undefined
my_var2
number
number
number
number
number
my_var1
Function: test
Object
number
string
number
undefined
string
my_var2
number
number
number
number
number
number
my_var1
Object
number
string
number
undefined
string
Object
my_var2
number
number
number
number
number
number
number
my_var1
Object
number
string
number
undefined
string
Object
Object
my_var2
number
number
number
number
number
number
number
number
Function
MyClass
Function
my_var
MyClass
my_var
MyClass
Object
my_var
MyClass
Object
number
*%(basename)s:34: throw otherwise test fails with --stress-opt
*%(basename)s:40: throw otherwise test fails with --stress-opt
throw "throw otherwise test fails with --stress-opt";
^
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment