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

Side by Side Diff: src/messages.cc

Issue 6606002: Merge revision 6500-6600 from bleeding_edge to the isolates branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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
« src/ast.cc ('K') | « 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 loc->start_pos(), *str); 54 loc->start_pos(), *str);
55 } 55 }
56 } 56 }
57 57
58 58
59 void MessageHandler::ReportMessage(const char* msg) { 59 void MessageHandler::ReportMessage(const char* msg) {
60 PrintF("%s\n", msg); 60 PrintF("%s\n", msg);
61 } 61 }
62 62
63 63
64 Handle<Object> MessageHandler::MakeMessageObject( 64 Handle<JSMessageObject> MessageHandler::MakeMessageObject(
65 const char* type, 65 const char* type,
66 MessageLocation* loc, 66 MessageLocation* loc,
67 Vector< Handle<Object> > args, 67 Vector< Handle<Object> > args,
68 Handle<String> stack_trace, 68 Handle<String> stack_trace,
69 Handle<JSArray> stack_frames) { 69 Handle<JSArray> stack_frames) {
70 // Build error message object 70 Handle<String> type_handle = FACTORY->LookupAsciiSymbol(type);
71 v8::HandleScope scope; // Instantiate a closeable HandleScope for EscapeFrom. 71 Handle<JSArray> arguments_handle = FACTORY->NewJSArray(args.length());
72 Handle<Object> type_str = FACTORY->LookupAsciiSymbol(type); 72 for (int i = 0; i < args.length(); i++) {
73 Handle<Object> array = FACTORY->NewJSArray(args.length()); 73 SetElement(arguments_handle, i, args[i]);
74 for (int i = 0; i < args.length(); i++) 74 }
75 SetElement(Handle<JSArray>::cast(array), i, args[i]);
76 75
77 Handle<JSFunction> fun( 76 int start = 0;
78 Isolate::Current()->global_context()->make_message_fun()); 77 int end = 0;
79 int start, end; 78 Handle<Object> script_handle = FACTORY->undefined_value();
80 Handle<Object> script;
81 if (loc) { 79 if (loc) {
82 start = loc->start_pos(); 80 start = loc->start_pos();
83 end = loc->end_pos(); 81 end = loc->end_pos();
84 script = GetScriptWrapper(loc->script()); 82 script_handle = GetScriptWrapper(loc->script());
85 } else {
86 start = end = 0;
87 script = FACTORY->undefined_value();
88 } 83 }
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 84
106 // Setup a catch handler to catch exceptions in creating the message. This 85 Handle<Object> stack_trace_handle = stack_trace.is_null()
107 // handler is non-verbose to avoid calling MakeMessage recursively in case of 86 ? FACTORY->undefined_value()
108 // an exception. 87 : Handle<Object>::cast(stack_trace);
109 v8::TryCatch catcher;
110 catcher.SetVerbose(false);
111 catcher.SetCaptureMessage(false);
112 88
113 // Format the message. 89 Handle<Object> stack_frames_handle = stack_frames.is_null()
114 bool caught_exception = false; 90 ? FACTORY->undefined_value()
115 Handle<Object> message = 91 : Handle<Object>::cast(stack_frames);
116 Execution::Call(fun, FACTORY->undefined_value(), argc, argv,
117 &caught_exception);
118 92
119 // If creating the message (in JS code) resulted in an exception, we 93 Handle<JSMessageObject> message =
120 // skip doing the callback. This usually only happens in case of 94 FACTORY->NewJSMessageObject(type_handle,
121 // stack overflow exceptions being thrown by the parser when the 95 arguments_handle,
122 // stack is almost full. 96 start,
123 if (caught_exception) return Handle<Object>(); 97 end,
98 script_handle,
99 stack_trace_handle,
100 stack_frames_handle);
124 101
125 return message.EscapeFrom(&scope); 102 return message;
126 } 103 }
127 104
128 105
129 void MessageHandler::ReportMessage(MessageLocation* loc, 106 void MessageHandler::ReportMessage(MessageLocation* loc,
130 Handle<Object> message) { 107 Handle<Object> message) {
131 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); 108 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message);
132 109
133 v8::NeanderArray global_listeners(FACTORY->message_listeners()); 110 v8::NeanderArray global_listeners(FACTORY->message_listeners());
134 int global_length = global_listeners.length(); 111 int global_length = global_listeners.length();
135 if (global_length == 0) { 112 if (global_length == 0) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 154 }
178 155
179 156
180 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { 157 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) {
181 HandleScope scope; 158 HandleScope scope;
182 return GetMessage(data)->ToCString(DISALLOW_NULLS); 159 return GetMessage(data)->ToCString(DISALLOW_NULLS);
183 } 160 }
184 161
185 162
186 } } // namespace v8::internal 163 } } // namespace v8::internal
OLDNEW
« src/ast.cc ('K') | « src/messages.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698