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

Side by Side Diff: src/runtime.cc

Issue 8357004: Add flag to tracing element kind transitions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: disable flags Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 8995 matching lines...) Expand 10 before | Expand all | Expand 10 after
9006 // First check if this is a real stack overflow. 9006 // First check if this is a real stack overflow.
9007 if (isolate->stack_guard()->IsStackOverflow()) { 9007 if (isolate->stack_guard()->IsStackOverflow()) {
9008 NoHandleAllocation na; 9008 NoHandleAllocation na;
9009 return isolate->StackOverflow(); 9009 return isolate->StackOverflow();
9010 } 9010 }
9011 9011
9012 return Execution::HandleStackGuardInterrupt(); 9012 return Execution::HandleStackGuardInterrupt();
9013 } 9013 }
9014 9014
9015 9015
9016 // NOTE: These PrintXXX functions are defined for all builds (not just
9017 // DEBUG builds) because we may want to be able to trace function
9018 // calls in all modes.
9019 static void PrintString(String* str) {
9020 // not uncommon to have empty strings
9021 if (str->length() > 0) {
9022 SmartArrayPointer<char> s =
9023 str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
9024 PrintF("%s", *s);
9025 }
9026 }
9027
9028
9029 static void PrintObject(Object* obj) {
9030 if (obj->IsSmi()) {
9031 PrintF("%d", Smi::cast(obj)->value());
9032 } else if (obj->IsString() || obj->IsSymbol()) {
9033 PrintString(String::cast(obj));
9034 } else if (obj->IsNumber()) {
9035 PrintF("%g", obj->Number());
9036 } else if (obj->IsFailure()) {
9037 PrintF("<failure>");
9038 } else if (obj->IsUndefined()) {
9039 PrintF("<undefined>");
9040 } else if (obj->IsNull()) {
9041 PrintF("<null>");
9042 } else if (obj->IsTrue()) {
9043 PrintF("<true>");
9044 } else if (obj->IsFalse()) {
9045 PrintF("<false>");
9046 } else {
9047 PrintF("%p", reinterpret_cast<void*>(obj));
9048 }
9049 }
9050
9051
9052 static int StackSize() { 9016 static int StackSize() {
9053 int n = 0; 9017 int n = 0;
9054 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) n++; 9018 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) n++;
9055 return n; 9019 return n;
9056 } 9020 }
9057 9021
9058 9022
9059 static void PrintTransition(Object* result) { 9023 static void PrintTransition(Object* result) {
9060 // indentation 9024 // indentation
9061 { const int nmax = 80; 9025 { const int nmax = 80;
9062 int n = StackSize(); 9026 int n = StackSize();
9063 if (n <= nmax) 9027 if (n <= nmax)
9064 PrintF("%4d:%*s", n, n, ""); 9028 PrintF("%4d:%*s", n, n, "");
9065 else 9029 else
9066 PrintF("%4d:%*s", n, nmax, "..."); 9030 PrintF("%4d:%*s", n, nmax, "...");
9067 } 9031 }
9068 9032
9069 if (result == NULL) { 9033 if (result == NULL) {
9070 // constructor calls 9034 JavaScriptFrame::PrintTop(stdout, true, false);
9071 JavaScriptFrameIterator it; 9035 PrintF(" {\n");
9072 JavaScriptFrame* frame = it.frame();
9073 if (frame->IsConstructor()) PrintF("new ");
9074 // function name
9075 Object* fun = frame->function();
9076 if (fun->IsJSFunction()) {
9077 PrintObject(JSFunction::cast(fun)->shared()->name());
9078 } else {
9079 PrintObject(fun);
9080 }
9081 // function arguments
9082 // (we are intentionally only printing the actually
9083 // supplied parameters, not all parameters required)
9084 PrintF("(this=");
9085 PrintObject(frame->receiver());
9086 const int length = frame->ComputeParametersCount();
9087 for (int i = 0; i < length; i++) {
9088 PrintF(", ");
9089 PrintObject(frame->GetParameter(i));
9090 }
9091 PrintF(") {\n");
9092
9093 } else { 9036 } else {
9094 // function result 9037 // function result
9095 PrintF("} -> "); 9038 PrintF("} -> ");
9096 PrintObject(result); 9039 result->ShortPrint();
9097 PrintF("\n"); 9040 PrintF("\n");
9098 } 9041 }
9099 } 9042 }
9100 9043
9101 9044
9045 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceElementsKindTransition) {
9046 ASSERT(args.length() == 5);
9047 CONVERT_ARG_CHECKED(JSObject, obj, 0);
9048 CONVERT_SMI_ARG_CHECKED(from_kind, 1);
9049 CONVERT_ARG_CHECKED(FixedArrayBase, from_elements, 2);
9050 CONVERT_SMI_ARG_CHECKED(to_kind, 3);
9051 CONVERT_ARG_CHECKED(FixedArrayBase, to_elements, 4);
9052 NoHandleAllocation ha;
9053 PrintF("*");
9054 obj->PrintElementsTransition(stdout,
9055 static_cast<ElementsKind>(from_kind), *from_elements,
9056 static_cast<ElementsKind>(to_kind), *to_elements);
9057 return isolate->heap()->undefined_value();
9058 }
9059
9060
9102 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { 9061 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) {
9103 ASSERT(args.length() == 0); 9062 ASSERT(args.length() == 0);
9104 NoHandleAllocation ha; 9063 NoHandleAllocation ha;
9105 PrintTransition(NULL); 9064 PrintTransition(NULL);
9106 return isolate->heap()->undefined_value(); 9065 return isolate->heap()->undefined_value();
9107 } 9066 }
9108 9067
9109 9068
9110 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { 9069 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) {
9111 NoHandleAllocation ha; 9070 NoHandleAllocation ha;
(...skipping 4307 matching lines...) Expand 10 before | Expand all | Expand 10 after
13419 } else { 13378 } else {
13420 // Handle last resort GC and make sure to allow future allocations 13379 // Handle last resort GC and make sure to allow future allocations
13421 // to grow the heap without causing GCs (if possible). 13380 // to grow the heap without causing GCs (if possible).
13422 isolate->counters()->gc_last_resort_from_js()->Increment(); 13381 isolate->counters()->gc_last_resort_from_js()->Increment();
13423 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13382 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13424 } 13383 }
13425 } 13384 }
13426 13385
13427 13386
13428 } } // namespace v8::internal 13387 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698