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

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: Created 9 years 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
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> stackFrame = factory()->NewJSObject(object_function());
Kevin Millikin (Chromium) 2012/01/04 13:00:32 We don't use camelCaseIdentifiers for local variab
ulan 2012/01/05 11:16:35 Done.
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 JSObject::SetLocalPropertyNoThrow(
595 Handle<Smi>(Smi::FromInt(column_offset + 1))); 595 stackFrame, column_key,
596 Handle<Smi>(Smi::FromInt(column_offset + 1)));
596 } 597 }
597 SetLocalPropertyNoThrow(stackFrame, line_key, 598 JSObject::SetLocalPropertyNoThrow(
598 Handle<Smi>(Smi::FromInt(line_number + 1))); 599 stackFrame, line_key, Handle<Smi>(Smi::FromInt(line_number + 1)));
599 } 600 }
600 601
601 if (options & StackTrace::kScriptName) { 602 if (options & StackTrace::kScriptName) {
602 Handle<Object> script_name(script->name(), this); 603 Handle<Object> script_name(script->name(), this);
603 SetLocalPropertyNoThrow(stackFrame, script_key, script_name); 604 JSObject::SetLocalPropertyNoThrow(stackFrame, script_key, script_name);
604 } 605 }
605 606
606 if (options & StackTrace::kScriptNameOrSourceURL) { 607 if (options & StackTrace::kScriptNameOrSourceURL) {
607 Handle<Object> script_name(script->name(), this); 608 Handle<Object> script_name(script->name(), this);
608 Handle<JSValue> script_wrapper = GetScriptWrapper(script); 609 Handle<JSValue> script_wrapper = GetScriptWrapper(script);
609 Handle<Object> property = GetProperty(script_wrapper, 610 Handle<Object> property = GetProperty(script_wrapper,
610 name_or_source_url_key); 611 name_or_source_url_key);
611 ASSERT(property->IsJSFunction()); 612 ASSERT(property->IsJSFunction());
612 Handle<JSFunction> method = Handle<JSFunction>::cast(property); 613 Handle<JSFunction> method = Handle<JSFunction>::cast(property);
613 bool caught_exception; 614 bool caught_exception;
614 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, 615 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0,
615 NULL, &caught_exception); 616 NULL, &caught_exception);
616 if (caught_exception) { 617 if (caught_exception) {
617 result = factory()->undefined_value(); 618 result = factory()->undefined_value();
618 } 619 }
619 SetLocalPropertyNoThrow(stackFrame, script_name_or_source_url_key, 620 JSObject::SetLocalPropertyNoThrow(
620 result); 621 stackFrame, script_name_or_source_url_key, result);
621 } 622 }
622 623
623 if (options & StackTrace::kFunctionName) { 624 if (options & StackTrace::kFunctionName) {
624 Handle<Object> fun_name(fun->shared()->name(), this); 625 Handle<Object> fun_name(fun->shared()->name(), this);
625 if (fun_name->ToBoolean()->IsFalse()) { 626 if (fun_name->ToBoolean()->IsFalse()) {
626 fun_name = Handle<Object>(fun->shared()->inferred_name(), this); 627 fun_name = Handle<Object>(fun->shared()->inferred_name(), this);
627 } 628 }
628 SetLocalPropertyNoThrow(stackFrame, function_key, fun_name); 629 JSObject::SetLocalPropertyNoThrow(stackFrame, function_key, fun_name);
629 } 630 }
630 631
631 if (options & StackTrace::kIsEval) { 632 if (options & StackTrace::kIsEval) {
632 int type = Smi::cast(script->compilation_type())->value(); 633 int type = Smi::cast(script->compilation_type())->value();
633 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ? 634 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ?
634 factory()->true_value() : factory()->false_value(); 635 factory()->true_value() : factory()->false_value();
635 SetLocalPropertyNoThrow(stackFrame, eval_key, is_eval); 636 JSObject::SetLocalPropertyNoThrow(stackFrame, eval_key, is_eval);
636 } 637 }
637 638
638 if (options & StackTrace::kIsConstructor) { 639 if (options & StackTrace::kIsConstructor) {
639 Handle<Object> is_constructor = (frames[i].is_constructor()) ? 640 Handle<Object> is_constructor = (frames[i].is_constructor()) ?
640 factory()->true_value() : factory()->false_value(); 641 factory()->true_value() : factory()->false_value();
641 SetLocalPropertyNoThrow(stackFrame, constructor_key, is_constructor); 642 JSObject::SetLocalPropertyNoThrow(
643 stackFrame, constructor_key, is_constructor);
642 } 644 }
643 645
644 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame); 646 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame);
645 frames_seen++; 647 frames_seen++;
646 } 648 }
647 it.Advance(); 649 it.Advance();
648 } 650 }
649 651
650 stack_trace->set_length(Smi::FromInt(frames_seen)); 652 stack_trace->set_length(Smi::FromInt(frames_seen));
651 return stack_trace; 653 return stack_trace;
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 1903
1902 #ifdef DEBUG 1904 #ifdef DEBUG
1903 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 1905 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
1904 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 1906 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
1905 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 1907 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
1906 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 1908 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
1907 #undef ISOLATE_FIELD_OFFSET 1909 #undef ISOLATE_FIELD_OFFSET
1908 #endif 1910 #endif
1909 1911
1910 } } // namespace v8::internal 1912 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698