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

Side by Side Diff: src/runtime/runtime-internal.cc

Issue 861623002: Add a pretty printer to improve the error message non-function calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment Created 5 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
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug.h" 9 #include "src/debug.h"
10 #include "src/messages.h"
11 #include "src/parser.h"
12 #include "src/prettyprinter.h"
10 #include "src/runtime/runtime-utils.h" 13 #include "src/runtime/runtime-utils.h"
11 14
12 namespace v8 { 15 namespace v8 {
13 namespace internal { 16 namespace internal {
14 17
15 RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) { 18 RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) {
16 SealHandleScope shs(isolate); 19 SealHandleScope shs(isolate);
17 DCHECK(args.length() == 0); 20 DCHECK(args.length() == 0);
18 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); 21 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
19 return isolate->heap()->undefined_value(); 22 return isolate->heap()->undefined_value();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (!isolate->bootstrapper()->IsActive()) { 149 if (!isolate->bootstrapper()->IsActive()) {
147 // Optionally capture a more detailed stack trace for the message. 150 // Optionally capture a more detailed stack trace for the message.
148 isolate->CaptureAndSetDetailedStackTrace(error_object); 151 isolate->CaptureAndSetDetailedStackTrace(error_object);
149 // Capture a simple stack trace for the stack property. 152 // Capture a simple stack trace for the stack property.
150 isolate->CaptureAndSetSimpleStackTrace(error_object, caller); 153 isolate->CaptureAndSetSimpleStackTrace(error_object, caller);
151 } 154 }
152 return isolate->heap()->undefined_value(); 155 return isolate->heap()->undefined_value();
153 } 156 }
154 157
155 158
159 RUNTIME_FUNCTION(Runtime_RenderCallSite) {
160 HandleScope scope(isolate);
161 DCHECK(args.length() == 0);
162 MessageLocation location;
163 isolate->ComputeLocation(&location);
164 if (location.start_pos() == -1) return isolate->heap()->empty_string();
165
166 Zone zone(isolate);
167 if (location.function()->shared()->is_function()) {
168 CompilationInfo info(location.function(), &zone);
169 if (!Parser::Parse(&info)) return isolate->heap()->empty_string();
170 CallPrinter printer(&zone);
171 const char* string = printer.Print(info.function(), location.start_pos());
172 return *isolate->factory()->NewStringFromAsciiChecked(string);
173 }
174
175 CompilationInfo info(location.script(), &zone);
176 if (!Parser::Parse(&info)) return isolate->heap()->empty_string();
177 CallPrinter printer(&zone);
178 const char* string = printer.Print(info.function(), location.start_pos());
179 return *isolate->factory()->NewStringFromAsciiChecked(string);
180 }
181
182
156 RUNTIME_FUNCTION(Runtime_GetFromCache) { 183 RUNTIME_FUNCTION(Runtime_GetFromCache) {
157 SealHandleScope shs(isolate); 184 SealHandleScope shs(isolate);
158 // This is only called from codegen, so checks might be more lax. 185 // This is only called from codegen, so checks might be more lax.
159 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); 186 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0);
160 CONVERT_ARG_CHECKED(Object, key, 1); 187 CONVERT_ARG_CHECKED(Object, key, 1);
161 188
162 { 189 {
163 DisallowHeapAllocation no_alloc; 190 DisallowHeapAllocation no_alloc;
164 191
165 int finger_index = cache->finger_index(); 192 int finger_index = cache->finger_index();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 300
274 RUNTIME_FUNCTION(RuntimeReference_GetFromCache) { 301 RUNTIME_FUNCTION(RuntimeReference_GetFromCache) {
275 HandleScope scope(isolate); 302 HandleScope scope(isolate);
276 DCHECK(args.length() == 2); 303 DCHECK(args.length() == 2);
277 CONVERT_SMI_ARG_CHECKED(id, 0); 304 CONVERT_SMI_ARG_CHECKED(id, 0);
278 args[0] = isolate->native_context()->jsfunction_result_caches()->get(id); 305 args[0] = isolate->native_context()->jsfunction_result_caches()->get(id);
279 return __RT_impl_Runtime_GetFromCache(args, isolate); 306 return __RT_impl_Runtime_GetFromCache(args, isolate);
280 } 307 }
281 } 308 }
282 } // namespace v8::internal 309 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698