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

Side by Side Diff: src/messages.cc

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 10 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/messages.h ('k') | src/messages.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 1
2 // Copyright 2006-2008 the V8 project authors. All rights reserved. 2 // Copyright 2006-2008 the V8 project authors. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following 10 // copyright notice, this list of conditions and the following
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 loc->start_pos(), *str); 55 loc->start_pos(), *str);
56 } 56 }
57 } 57 }
58 58
59 59
60 void MessageHandler::ReportMessage(const char* msg) { 60 void MessageHandler::ReportMessage(const char* msg) {
61 PrintF("%s\n", msg); 61 PrintF("%s\n", msg);
62 } 62 }
63 63
64 64
65 Handle<Object> MessageHandler::MakeMessageObject( 65 Handle<JSMessageObject> MessageHandler::MakeMessageObject(
66 const char* type, 66 const char* type,
67 MessageLocation* loc, 67 MessageLocation* loc,
68 Vector< Handle<Object> > args, 68 Vector< Handle<Object> > args,
69 Handle<String> stack_trace, 69 Handle<String> stack_trace,
70 Handle<JSArray> stack_frames) { 70 Handle<JSArray> stack_frames) {
71 // Build error message object 71 Handle<String> type_handle = Factory::LookupAsciiSymbol(type);
72 v8::HandleScope scope; // Instantiate a closeable HandleScope for EscapeFrom. 72 Handle<FixedArray> arguments_elements =
73 Handle<Object> type_str = Factory::LookupAsciiSymbol(type); 73 Factory::NewFixedArray(args.length());
74 Handle<Object> array = Factory::NewJSArray(args.length()); 74 for (int i = 0; i < args.length(); i++) {
75 for (int i = 0; i < args.length(); i++) 75 arguments_elements->set(i, *args[i]);
76 SetElement(Handle<JSArray>::cast(array), i, args[i]); 76 }
77 Handle<JSArray> arguments_handle =
78 Factory::NewJSArrayWithElements(arguments_elements);
77 79
78 Handle<JSFunction> fun(Top::global_context()->make_message_fun()); 80 int start = 0;
79 int start, end; 81 int end = 0;
80 Handle<Object> script; 82 Handle<Object> script_handle = Factory::undefined_value();
81 if (loc) { 83 if (loc) {
82 start = loc->start_pos(); 84 start = loc->start_pos();
83 end = loc->end_pos(); 85 end = loc->end_pos();
84 script = GetScriptWrapper(loc->script()); 86 script_handle = GetScriptWrapper(loc->script());
85 } else {
86 start = end = 0;
87 script = Factory::undefined_value();
88 } 87 }
89 Handle<Object> start_handle(Smi::FromInt(start));
90 Handle<Object> end_handle(Smi::FromInt(end));
91 Handle<Object> stack_trace_val = stack_trace.is_null()
92 ? Factory::undefined_value()
93 : Handle<Object>::cast(stack_trace);
94 Handle<Object> stack_frames_val = stack_frames.is_null()
95 ? Factory::undefined_value()
96 : Handle<Object>::cast(stack_frames);
97 const int argc = 7;
98 Object** argv[argc] = { type_str.location(),
99 array.location(),
100 start_handle.location(),
101 end_handle.location(),
102 script.location(),
103 stack_trace_val.location(),
104 stack_frames_val.location() };
105 88
106 // Setup a catch handler to catch exceptions in creating the message. This 89 Handle<Object> stack_trace_handle = stack_trace.is_null()
107 // handler is non-verbose to avoid calling MakeMessage recursively in case of 90 ? Factory::undefined_value()
108 // an exception. 91 : Handle<Object>::cast(stack_trace);
109 v8::TryCatch catcher;
110 catcher.SetVerbose(false);
111 catcher.SetCaptureMessage(false);
112 92
113 // Format the message. 93 Handle<Object> stack_frames_handle = stack_frames.is_null()
114 bool caught_exception = false; 94 ? Factory::undefined_value()
115 Handle<Object> message = 95 : Handle<Object>::cast(stack_frames);
116 Execution::Call(fun, Factory::undefined_value(), argc, argv,
117 &caught_exception);
118 96
119 // If creating the message (in JS code) resulted in an exception, we 97 Handle<JSMessageObject> message =
120 // skip doing the callback. This usually only happens in case of 98 Factory::NewJSMessageObject(type_handle,
121 // stack overflow exceptions being thrown by the parser when the 99 arguments_handle,
122 // stack is almost full. 100 start,
123 if (caught_exception) return Handle<Object>(); 101 end,
102 script_handle,
103 stack_trace_handle,
104 stack_frames_handle);
124 105
125 return message.EscapeFrom(&scope); 106 return message;
126 } 107 }
127 108
128 109
129 void MessageHandler::ReportMessage(MessageLocation* loc, 110 void MessageHandler::ReportMessage(MessageLocation* loc,
130 Handle<Object> message) { 111 Handle<Object> message) {
131 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); 112 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message);
132 113
133 v8::NeanderArray global_listeners(Factory::message_listeners()); 114 v8::NeanderArray global_listeners(Factory::message_listeners());
134 int global_length = global_listeners.length(); 115 int global_length = global_listeners.length();
135 if (global_length == 0) { 116 if (global_length == 0) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 155 }
175 156
176 157
177 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { 158 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) {
178 HandleScope scope; 159 HandleScope scope;
179 return GetMessage(data)->ToCString(DISALLOW_NULLS); 160 return GetMessage(data)->ToCString(DISALLOW_NULLS);
180 } 161 }
181 162
182 163
183 } } // namespace v8::internal 164 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698