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

Unified Diff: src/runtime/runtime-object.cc

Issue 2707873002: Collect type profile for DevTools. (Closed)
Patch Set: Use constructor name if available. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: src/runtime/runtime-object.cc
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index dd24728457d2fab4b5fdb1d284e3116849bc0276..761cf82bba1a7097087d360a4d6fc6b6fe793a88 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <src/ic/ic-state.h>
#include "src/runtime/runtime-utils.h"
#include "src/arguments.h"
@@ -680,6 +681,59 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) {
return *object;
}
+RUNTIME_FUNCTION(Runtime_StoreTypeInformation) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(4, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
+ CONVERT_ARG_HANDLE_CHECKED(FeedbackVector, vector, 2);
+ CONVERT_SMI_ARG_CHECKED(index, 3);
+
+ DCHECK(FLAG_type_profile);
+
+ CollectTypeProfileICNexus nexus(vector, vector->ToSlot(index));
Yang 2017/02/22 10:39:28 Do we need to fit this into the IC framework? We d
Franzi 2017/02/27 11:38:01 Yes, IC framework makes no sense for types. Simpli
+
+ // We've seen to much. Nothing to see here
+ if (nexus.ic_state() == MEGAMORPHIC) {
+ name->Print();
+ printf("Too many types to list them.\n\n");
+ return *name;
+ }
+
+ Handle<Name> type = Object::TypeOf(isolate, value);
+ if (value->IsJSReceiver()) {
+ Handle<JSReceiver> object = Handle<JSReceiver>::cast(value);
+ type = JSReceiver::GetConstructorName(object);
+ }
+ if (nexus.ic_state() == UNINITIALIZED) {
+ nexus.ConfigureMonomorphic(type);
+ } else if (nexus.ic_state() == MONOMORPHIC) {
+ DCHECK(nexus.GetFeedback()->IsName());
+ Handle<Name> known_type =
+ Handle<Name>::cast(Handle<Object>(nexus.GetFeedback(), isolate));
+ // Do not store the value if it is the same type.
+ if (!known_type->Equals(*type)) {
+ nexus.ConfigurePolymorphic(type);
+ }
+ } else {
+ DCHECK(nexus.ic_state() == POLYMORPHIC);
+ DCHECK(nexus.GetFeedback()->IsArrayList());
+ Handle<ArrayList> known_types =
+ Handle<ArrayList>::cast(Handle<Object>(nexus.GetFeedback(), isolate));
+ if (known_types->Length() == kMaxKeyedPolymorphism) {
+ nexus.ConfigureMegamorphic();
+ return *name;
+ }
+ nexus.ConfigurePolymorphic(type);
+ }
+
+ name->Print();
+ nexus.GetFeedback()->Print();
+ printf("\n");
+
+ return *name;
+}
+
// Return property without being observable by accessors or interceptors.
RUNTIME_FUNCTION(Runtime_GetDataProperty) {
HandleScope scope(isolate);

Powered by Google App Engine
This is Rietveld 408576698