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

Side by Side Diff: src/isolate.cc

Issue 9008012: Move handlified functions from handles.cc to objects.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: More formatting fixes. Created 8 years, 11 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/isolate.h ('k') | src/json-parser.h » ('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 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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 StackTraceFrameIterator it(this); 563 StackTraceFrameIterator it(this);
564 int frames_seen = 0; 564 int frames_seen = 0;
565 while (!it.done() && (frames_seen < limit)) { 565 while (!it.done() && (frames_seen < limit)) {
566 JavaScriptFrame* frame = it.frame(); 566 JavaScriptFrame* frame = it.frame();
567 // Set initial size to the maximum inlining level + 1 for the outermost 567 // Set initial size to the maximum inlining level + 1 for the outermost
568 // function. 568 // function.
569 List<FrameSummary> frames(Compiler::kMaxInliningLevels + 1); 569 List<FrameSummary> frames(Compiler::kMaxInliningLevels + 1);
570 frame->Summarize(&frames); 570 frame->Summarize(&frames);
571 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { 571 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
572 // Create a JSObject to hold the information for the StackFrame. 572 // Create a JSObject to hold the information for the StackFrame.
573 Handle<JSObject> stackFrame = factory()->NewJSObject(object_function()); 573 Handle<JSObject> stack_frame = factory()->NewJSObject(object_function());
574 574
575 Handle<JSFunction> fun = frames[i].function(); 575 Handle<JSFunction> fun = frames[i].function();
576 Handle<Script> script(Script::cast(fun->shared()->script())); 576 Handle<Script> script(Script::cast(fun->shared()->script()));
577 577
578 if (options & StackTrace::kLineNumber) { 578 if (options & StackTrace::kLineNumber) {
579 int script_line_offset = script->line_offset()->value(); 579 int script_line_offset = script->line_offset()->value();
580 int position = frames[i].code()->SourcePosition(frames[i].pc()); 580 int position = frames[i].code()->SourcePosition(frames[i].pc());
581 int line_number = GetScriptLineNumber(script, position); 581 int line_number = GetScriptLineNumber(script, position);
582 // line_number is already shifted by the script_line_offset. 582 // line_number is already shifted by the script_line_offset.
583 int relative_line_number = line_number - script_line_offset; 583 int relative_line_number = line_number - script_line_offset;
584 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { 584 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) {
585 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); 585 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
586 int start = (relative_line_number == 0) ? 0 : 586 int start = (relative_line_number == 0) ? 0 :
587 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; 587 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1;
588 int column_offset = position - start; 588 int column_offset = position - start;
589 if (relative_line_number == 0) { 589 if (relative_line_number == 0) {
590 // For the case where the code is on the same line as the script 590 // For the case where the code is on the same line as the script
591 // tag. 591 // tag.
592 column_offset += script->column_offset()->value(); 592 column_offset += script->column_offset()->value();
593 } 593 }
594 SetLocalPropertyNoThrow(stackFrame, column_key, 594 CHECK_NOT_EMPTY_HANDLE(
595 Handle<Smi>(Smi::FromInt(column_offset + 1))); 595 this,
596 JSObject::SetLocalPropertyIgnoreAttributes(
597 stack_frame, column_key,
598 Handle<Smi>(Smi::FromInt(column_offset + 1)), NONE));
596 } 599 }
597 SetLocalPropertyNoThrow(stackFrame, line_key, 600 CHECK_NOT_EMPTY_HANDLE(
598 Handle<Smi>(Smi::FromInt(line_number + 1))); 601 this,
602 JSObject::SetLocalPropertyIgnoreAttributes(
603 stack_frame, line_key,
604 Handle<Smi>(Smi::FromInt(line_number + 1)), NONE));
599 } 605 }
600 606
601 if (options & StackTrace::kScriptName) { 607 if (options & StackTrace::kScriptName) {
602 Handle<Object> script_name(script->name(), this); 608 Handle<Object> script_name(script->name(), this);
603 SetLocalPropertyNoThrow(stackFrame, script_key, script_name); 609 CHECK_NOT_EMPTY_HANDLE(this,
610 JSObject::SetLocalPropertyIgnoreAttributes(
611 stack_frame, script_key, script_name, NONE));
604 } 612 }
605 613
606 if (options & StackTrace::kScriptNameOrSourceURL) { 614 if (options & StackTrace::kScriptNameOrSourceURL) {
607 Handle<Object> script_name(script->name(), this); 615 Handle<Object> script_name(script->name(), this);
608 Handle<JSValue> script_wrapper = GetScriptWrapper(script); 616 Handle<JSValue> script_wrapper = GetScriptWrapper(script);
609 Handle<Object> property = GetProperty(script_wrapper, 617 Handle<Object> property = GetProperty(script_wrapper,
610 name_or_source_url_key); 618 name_or_source_url_key);
611 ASSERT(property->IsJSFunction()); 619 ASSERT(property->IsJSFunction());
612 Handle<JSFunction> method = Handle<JSFunction>::cast(property); 620 Handle<JSFunction> method = Handle<JSFunction>::cast(property);
613 bool caught_exception; 621 bool caught_exception;
614 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, 622 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0,
615 NULL, &caught_exception); 623 NULL, &caught_exception);
616 if (caught_exception) { 624 if (caught_exception) {
617 result = factory()->undefined_value(); 625 result = factory()->undefined_value();
618 } 626 }
619 SetLocalPropertyNoThrow(stackFrame, script_name_or_source_url_key, 627 CHECK_NOT_EMPTY_HANDLE(this,
620 result); 628 JSObject::SetLocalPropertyIgnoreAttributes(
629 stack_frame, script_name_or_source_url_key,
630 result, NONE));
621 } 631 }
622 632
623 if (options & StackTrace::kFunctionName) { 633 if (options & StackTrace::kFunctionName) {
624 Handle<Object> fun_name(fun->shared()->name(), this); 634 Handle<Object> fun_name(fun->shared()->name(), this);
625 if (fun_name->ToBoolean()->IsFalse()) { 635 if (fun_name->ToBoolean()->IsFalse()) {
626 fun_name = Handle<Object>(fun->shared()->inferred_name(), this); 636 fun_name = Handle<Object>(fun->shared()->inferred_name(), this);
627 } 637 }
628 SetLocalPropertyNoThrow(stackFrame, function_key, fun_name); 638 CHECK_NOT_EMPTY_HANDLE(this,
639 JSObject::SetLocalPropertyIgnoreAttributes(
640 stack_frame, function_key, fun_name, NONE));
629 } 641 }
630 642
631 if (options & StackTrace::kIsEval) { 643 if (options & StackTrace::kIsEval) {
632 int type = Smi::cast(script->compilation_type())->value(); 644 int type = Smi::cast(script->compilation_type())->value();
633 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ? 645 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ?
634 factory()->true_value() : factory()->false_value(); 646 factory()->true_value() : factory()->false_value();
635 SetLocalPropertyNoThrow(stackFrame, eval_key, is_eval); 647 CHECK_NOT_EMPTY_HANDLE(this,
648 JSObject::SetLocalPropertyIgnoreAttributes(
649 stack_frame, eval_key, is_eval, NONE));
636 } 650 }
637 651
638 if (options & StackTrace::kIsConstructor) { 652 if (options & StackTrace::kIsConstructor) {
639 Handle<Object> is_constructor = (frames[i].is_constructor()) ? 653 Handle<Object> is_constructor = (frames[i].is_constructor()) ?
640 factory()->true_value() : factory()->false_value(); 654 factory()->true_value() : factory()->false_value();
641 SetLocalPropertyNoThrow(stackFrame, constructor_key, is_constructor); 655 CHECK_NOT_EMPTY_HANDLE(this,
656 JSObject::SetLocalPropertyIgnoreAttributes(
657 stack_frame, constructor_key,
658 is_constructor, NONE));
642 } 659 }
643 660
644 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame); 661 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame);
645 frames_seen++; 662 frames_seen++;
646 } 663 }
647 it.Advance(); 664 it.Advance();
648 } 665 }
649 666
650 stack_trace->set_length(Smi::FromInt(frames_seen)); 667 stack_trace->set_length(Smi::FromInt(frames_seen));
651 return stack_trace; 668 return stack_trace;
652 } 669 }
653 670
654 671
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 1918
1902 #ifdef DEBUG 1919 #ifdef DEBUG
1903 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 1920 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
1904 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 1921 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
1905 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 1922 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
1906 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 1923 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
1907 #undef ISOLATE_FIELD_OFFSET 1924 #undef ISOLATE_FIELD_OFFSET
1908 #endif 1925 #endif
1909 1926
1910 } } // namespace v8::internal 1927 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/json-parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698