| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/isolate.h" | 5 #include "src/isolate.h" | 
| 6 | 6 | 
| 7 #include <stdlib.h> | 7 #include <stdlib.h> | 
| 8 | 8 | 
| 9 #include <fstream>  // NOLINT(readability/streams) | 9 #include <fstream>  // NOLINT(readability/streams) | 
| 10 #include <sstream> | 10 #include <sstream> | 
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 680     int frame_limit, StackTrace::StackTraceOptions options) { | 680     int frame_limit, StackTrace::StackTraceOptions options) { | 
| 681   CaptureStackTraceHelper helper(this, options); | 681   CaptureStackTraceHelper helper(this, options); | 
| 682 | 682 | 
| 683   // Ensure no negative values. | 683   // Ensure no negative values. | 
| 684   int limit = Max(frame_limit, 0); | 684   int limit = Max(frame_limit, 0); | 
| 685   Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); | 685   Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); | 
| 686 | 686 | 
| 687   StackTraceFrameIterator it(this); | 687   StackTraceFrameIterator it(this); | 
| 688   int frames_seen = 0; | 688   int frames_seen = 0; | 
| 689   while (!it.done() && (frames_seen < limit)) { | 689   while (!it.done() && (frames_seen < limit)) { | 
| 690     JavaScriptFrame* frame = it.frame(); | 690     StandardFrame* frame = it.frame(); | 
| 691     // Set initial size to the maximum inlining level + 1 for the outermost | 691     // Set initial size to the maximum inlining level + 1 for the outermost | 
| 692     // function. | 692     // function. | 
| 693     List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 693     List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 
| 694     frame->Summarize(&frames); | 694     frame->Summarize(&frames); | 
| 695     for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { | 695     for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { | 
| 696       Handle<JSFunction> fun = frames[i].function(); | 696       Handle<JSFunction> fun = frames[i].function(); | 
| 697       // Filter frames from other security contexts. | 697       // Filter frames from other security contexts. | 
| 698       if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && | 698       if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && | 
| 699           !this->context()->HasSameSecurityTokenAs(fun->context())) continue; | 699           !this->context()->HasSameSecurityTokenAs(fun->context())) continue; | 
| 700       int position = | 700       int position = | 
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1311   // Re-throw the exception to avoid getting repeated error reporting. | 1311   // Re-throw the exception to avoid getting repeated error reporting. | 
| 1312   return ReThrow(thrown); | 1312   return ReThrow(thrown); | 
| 1313 } | 1313 } | 
| 1314 | 1314 | 
| 1315 | 1315 | 
| 1316 void Isolate::PrintCurrentStackTrace(FILE* out) { | 1316 void Isolate::PrintCurrentStackTrace(FILE* out) { | 
| 1317   StackTraceFrameIterator it(this); | 1317   StackTraceFrameIterator it(this); | 
| 1318   while (!it.done()) { | 1318   while (!it.done()) { | 
| 1319     HandleScope scope(this); | 1319     HandleScope scope(this); | 
| 1320     // Find code position if recorded in relocation info. | 1320     // Find code position if recorded in relocation info. | 
| 1321     JavaScriptFrame* frame = it.frame(); | 1321     StandardFrame* frame = it.frame(); | 
| 1322     Code* code = frame->LookupCode(); | 1322     Code* code = frame->LookupCode(); | 
| 1323     int offset = static_cast<int>(frame->pc() - code->instruction_start()); | 1323     int offset = static_cast<int>(frame->pc() - code->instruction_start()); | 
| 1324     int pos = frame->LookupCode()->SourcePosition(offset); | 1324     int pos = frame->LookupCode()->SourcePosition(offset); | 
| 1325     Handle<Object> pos_obj(Smi::FromInt(pos), this); | 1325     Handle<Object> pos_obj(Smi::FromInt(pos), this); | 
| 1326     // Fetch function and receiver. | 1326     // Fetch function and receiver. | 
| 1327     Handle<JSFunction> fun(frame->function()); | 1327     Handle<JSFunction> fun(frame->function()); | 
| 1328     Handle<Object> recv(frame->receiver(), this); | 1328     Handle<Object> recv(frame->receiver(), this); | 
| 1329     // Advance to the next JavaScript frame and determine if the | 1329     // Advance to the next JavaScript frame and determine if the | 
| 1330     // current frame is the top-level frame. | 1330     // current frame is the top-level frame. | 
| 1331     it.Advance(); | 1331     it.Advance(); | 
| 1332     Handle<Object> is_top_level = factory()->ToBoolean(it.done()); | 1332     Handle<Object> is_top_level = factory()->ToBoolean(it.done()); | 
| 1333     // Generate and print stack trace line. | 1333     // Generate and print stack trace line. | 
| 1334     Handle<String> line = | 1334     Handle<String> line = | 
| 1335         Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); | 1335         Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); | 
| 1336     if (line->length() > 0) { | 1336     if (line->length() > 0) { | 
| 1337       line->PrintOn(out); | 1337       line->PrintOn(out); | 
| 1338       PrintF(out, "\n"); | 1338       PrintF(out, "\n"); | 
| 1339     } | 1339     } | 
| 1340   } | 1340   } | 
| 1341 } | 1341 } | 
| 1342 | 1342 | 
| 1343 | 1343 | 
| 1344 bool Isolate::ComputeLocation(MessageLocation* target) { | 1344 bool Isolate::ComputeLocation(MessageLocation* target) { | 
| 1345   StackTraceFrameIterator it(this); | 1345   StackTraceFrameIterator it(this); | 
| 1346   if (!it.done()) { | 1346   if (!it.done()) { | 
| 1347     JavaScriptFrame* frame = it.frame(); | 1347     StandardFrame* frame = it.frame(); | 
| 1348     JSFunction* fun = frame->function(); | 1348     JSFunction* fun = frame->function(); | 
| 1349     Object* script = fun->shared()->script(); | 1349     Object* script = fun->shared()->script(); | 
| 1350     if (script->IsScript() && | 1350     if (script->IsScript() && | 
| 1351         !(Script::cast(script)->source()->IsUndefined())) { | 1351         !(Script::cast(script)->source()->IsUndefined())) { | 
| 1352       Handle<Script> casted_script(Script::cast(script)); | 1352       Handle<Script> casted_script(Script::cast(script)); | 
| 1353       // Compute the location from the function and the relocation info of the | 1353       // Compute the location from the function and the relocation info of the | 
| 1354       // baseline code. For optimized code this will use the deoptimization | 1354       // baseline code. For optimized code this will use the deoptimization | 
| 1355       // information to get canonical location information. | 1355       // information to get canonical location information. | 
| 1356       List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 1356       List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 
| 1357       it.frame()->Summarize(&frames); | 1357       frame->Summarize(&frames); | 
| 1358       FrameSummary& summary = frames.last(); | 1358       FrameSummary& summary = frames.last(); | 
| 1359       int pos = summary.abstract_code()->SourcePosition(summary.code_offset()); | 1359       int pos = summary.abstract_code()->SourcePosition(summary.code_offset()); | 
| 1360       *target = MessageLocation(casted_script, pos, pos + 1, handle(fun)); | 1360       *target = MessageLocation(casted_script, pos, pos + 1, handle(fun)); | 
| 1361       return true; | 1361       return true; | 
| 1362     } | 1362     } | 
| 1363   } | 1363   } | 
| 1364   return false; | 1364   return false; | 
| 1365 } | 1365 } | 
| 1366 | 1366 | 
| 1367 | 1367 | 
| (...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2989   // Then check whether this scope intercepts. | 2989   // Then check whether this scope intercepts. | 
| 2990   if ((flag & intercept_mask_)) { | 2990   if ((flag & intercept_mask_)) { | 
| 2991     intercepted_flags_ |= flag; | 2991     intercepted_flags_ |= flag; | 
| 2992     return true; | 2992     return true; | 
| 2993   } | 2993   } | 
| 2994   return false; | 2994   return false; | 
| 2995 } | 2995 } | 
| 2996 | 2996 | 
| 2997 }  // namespace internal | 2997 }  // namespace internal | 
| 2998 }  // namespace v8 | 2998 }  // namespace v8 | 
| OLD | NEW | 
|---|