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

Side by Side Diff: src/isolate.cc

Issue 261103002: filter out .caller from other worlds (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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/contexts.h ('k') | test/mjsunit/cross-realm-filtering.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "ast.h" 9 #include "ast.h"
10 #include "bootstrapper.h" 10 #include "bootstrapper.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // First element is reserved to store the number of sloppy frames. 381 // First element is reserved to store the number of sloppy frames.
382 int cursor = 1; 382 int cursor = 1;
383 int frames_seen = 0; 383 int frames_seen = 0;
384 int sloppy_frames = 0; 384 int sloppy_frames = 0;
385 bool encountered_strict_function = false; 385 bool encountered_strict_function = false;
386 for (StackFrameIterator iter(this); 386 for (StackFrameIterator iter(this);
387 !iter.done() && frames_seen < limit; 387 !iter.done() && frames_seen < limit;
388 iter.Advance()) { 388 iter.Advance()) {
389 StackFrame* raw_frame = iter.frame(); 389 StackFrame* raw_frame = iter.frame();
390 if (IsVisibleInStackTrace(raw_frame, *caller, &seen_caller)) { 390 if (IsVisibleInStackTrace(raw_frame, *caller, &seen_caller)) {
391 frames_seen++;
392 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); 391 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame);
393 // Set initial size to the maximum inlining level + 1 for the outermost 392 // Set initial size to the maximum inlining level + 1 for the outermost
394 // function. 393 // function.
395 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); 394 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
396 frame->Summarize(&frames); 395 frame->Summarize(&frames);
397 for (int i = frames.length() - 1; i >= 0; i--) { 396 for (int i = frames.length() - 1; i >= 0; i--) {
397 Handle<JSFunction> fun = frames[i].function();
398 // Filter out frames from other security contexts.
399 if (!this->context()->HasSameSecurityTokenAs(fun->context())) continue;
398 if (cursor + 4 > elements->length()) { 400 if (cursor + 4 > elements->length()) {
399 int new_capacity = JSObject::NewElementsCapacity(elements->length()); 401 int new_capacity = JSObject::NewElementsCapacity(elements->length());
400 Handle<FixedArray> new_elements = 402 Handle<FixedArray> new_elements =
401 factory()->NewFixedArrayWithHoles(new_capacity); 403 factory()->NewFixedArrayWithHoles(new_capacity);
402 for (int i = 0; i < cursor; i++) { 404 for (int i = 0; i < cursor; i++) {
403 new_elements->set(i, elements->get(i)); 405 new_elements->set(i, elements->get(i));
404 } 406 }
405 elements = new_elements; 407 elements = new_elements;
406 } 408 }
407 ASSERT(cursor + 4 <= elements->length()); 409 ASSERT(cursor + 4 <= elements->length());
408 410
409 Handle<Object> recv = frames[i].receiver(); 411 Handle<Object> recv = frames[i].receiver();
410 Handle<JSFunction> fun = frames[i].function();
411 Handle<Code> code = frames[i].code(); 412 Handle<Code> code = frames[i].code();
412 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); 413 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this);
413 // The stack trace API should not expose receivers and function 414 // The stack trace API should not expose receivers and function
414 // objects on frames deeper than the top-most one with a strict 415 // objects on frames deeper than the top-most one with a strict
415 // mode function. The number of sloppy frames is stored as 416 // mode function. The number of sloppy frames is stored as
416 // first element in the result array. 417 // first element in the result array.
417 if (!encountered_strict_function) { 418 if (!encountered_strict_function) {
418 if (fun->shared()->strict_mode() == STRICT) { 419 if (fun->shared()->strict_mode() == STRICT) {
419 encountered_strict_function = true; 420 encountered_strict_function = true;
420 } else { 421 } else {
421 sloppy_frames++; 422 sloppy_frames++;
422 } 423 }
423 } 424 }
424 elements->set(cursor++, *recv); 425 elements->set(cursor++, *recv);
425 elements->set(cursor++, *fun); 426 elements->set(cursor++, *fun);
426 elements->set(cursor++, *code); 427 elements->set(cursor++, *code);
427 elements->set(cursor++, *offset); 428 elements->set(cursor++, *offset);
428 } 429 }
430 frames_seen++;
429 } 431 }
430 } 432 }
431 elements->set(0, Smi::FromInt(sloppy_frames)); 433 elements->set(0, Smi::FromInt(sloppy_frames));
432 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); 434 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements);
433 result->set_length(Smi::FromInt(cursor)); 435 result->set_length(Smi::FromInt(cursor));
434 return result; 436 return result;
435 } 437 }
436 438
437 439
438 void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object) { 440 void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 475
474 StackTraceFrameIterator it(this); 476 StackTraceFrameIterator it(this);
475 int frames_seen = 0; 477 int frames_seen = 0;
476 while (!it.done() && (frames_seen < limit)) { 478 while (!it.done() && (frames_seen < limit)) {
477 JavaScriptFrame* frame = it.frame(); 479 JavaScriptFrame* frame = it.frame();
478 // Set initial size to the maximum inlining level + 1 for the outermost 480 // Set initial size to the maximum inlining level + 1 for the outermost
479 // function. 481 // function.
480 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); 482 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
481 frame->Summarize(&frames); 483 frame->Summarize(&frames);
482 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { 484 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
485 Handle<JSFunction> fun = frames[i].function();
486 // Filter frames from other security contexts.
487 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) &&
488 !this->context()->HasSameSecurityTokenAs(fun->context())) continue;
489
483 // Create a JSObject to hold the information for the StackFrame. 490 // Create a JSObject to hold the information for the StackFrame.
484 Handle<JSObject> stack_frame = factory()->NewJSObject(object_function()); 491 Handle<JSObject> stack_frame = factory()->NewJSObject(object_function());
485 492
486 Handle<JSFunction> fun = frames[i].function();
487 Handle<Script> script(Script::cast(fun->shared()->script())); 493 Handle<Script> script(Script::cast(fun->shared()->script()));
488 494
489 if (options & StackTrace::kLineNumber) { 495 if (options & StackTrace::kLineNumber) {
490 int script_line_offset = script->line_offset()->value(); 496 int script_line_offset = script->line_offset()->value();
491 int position = frames[i].code()->SourcePosition(frames[i].pc()); 497 int position = frames[i].code()->SourcePosition(frames[i].pc());
492 int line_number = Script::GetLineNumber(script, position); 498 int line_number = Script::GetLineNumber(script, position);
493 // line_number is already shifted by the script_line_offset. 499 // line_number is already shifted by the script_line_offset.
494 int relative_line_number = line_number - script_line_offset; 500 int relative_line_number = line_number - script_line_offset;
495 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { 501 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) {
496 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); 502 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 Execution::Call(this, microtask, factory()->undefined_value(), 2295 Execution::Call(this, microtask, factory()->undefined_value(),
2290 0, NULL).Check(); 2296 0, NULL).Check();
2291 } 2297 }
2292 } 2298 }
2293 2299
2294 handle_scope_implementer()->DecrementCallDepth(); 2300 handle_scope_implementer()->DecrementCallDepth();
2295 } 2301 }
2296 2302
2297 2303
2298 } } // namespace v8::internal 2304 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | test/mjsunit/cross-realm-filtering.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698