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

Side by Side Diff: src/json-stringifier.h

Issue 516913003: Do not expose termination exceptions to the Exception API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comment Created 6 years, 3 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/json-parser.h ('k') | src/jsregexp.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #ifndef V8_JSON_STRINGIFIER_H_ 5 #ifndef V8_JSON_STRINGIFIER_H_
6 #define V8_JSON_STRINGIFIER_H_ 6 #define V8_JSON_STRINGIFIER_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 252
253 253
254 MaybeHandle<Object> BasicJsonStringifier::Stringify(Handle<Object> object) { 254 MaybeHandle<Object> BasicJsonStringifier::Stringify(Handle<Object> object) {
255 Result result = SerializeObject(object); 255 Result result = SerializeObject(object);
256 if (result == UNCHANGED) return isolate_->factory()->undefined_value(); 256 if (result == UNCHANGED) return isolate_->factory()->undefined_value();
257 if (result == SUCCESS) { 257 if (result == SUCCESS) {
258 ShrinkCurrentPart(); 258 ShrinkCurrentPart();
259 Accumulate(); 259 Accumulate();
260 if (overflowed_) { 260 if (overflowed_) {
261 return isolate_->Throw<Object>( 261 THROW_NEW_ERROR(isolate_, NewInvalidStringLengthError(), Object);
262 isolate_->factory()->NewInvalidStringLengthError());
263 } 262 }
264 return accumulator(); 263 return accumulator();
265 } 264 }
266 DCHECK(result == EXCEPTION); 265 DCHECK(result == EXCEPTION);
267 return MaybeHandle<Object>(); 266 return MaybeHandle<Object>();
268 } 267 }
269 268
270 269
271 MaybeHandle<Object> BasicJsonStringifier::StringifyString( 270 MaybeHandle<Object> BasicJsonStringifier::StringifyString(
272 Isolate* isolate, Handle<String> object) { 271 Isolate* isolate, Handle<String> object) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 return EXCEPTION; 364 return EXCEPTION;
366 } 365 }
367 366
368 int length = Smi::cast(stack_->length())->value(); 367 int length = Smi::cast(stack_->length())->value();
369 { 368 {
370 DisallowHeapAllocation no_allocation; 369 DisallowHeapAllocation no_allocation;
371 FixedArray* elements = FixedArray::cast(stack_->elements()); 370 FixedArray* elements = FixedArray::cast(stack_->elements());
372 for (int i = 0; i < length; i++) { 371 for (int i = 0; i < length; i++) {
373 if (elements->get(i) == *object) { 372 if (elements->get(i) == *object) {
374 AllowHeapAllocation allow_to_return_error; 373 AllowHeapAllocation allow_to_return_error;
375 isolate_->Throw(*factory_->NewTypeError( 374 Handle<Object> error;
376 "circular_structure", HandleVector<Object>(NULL, 0))); 375 MaybeHandle<Object> maybe_error = factory_->NewTypeError(
376 "circular_structure", HandleVector<Object>(NULL, 0));
377 if (maybe_error.ToHandle(&error)) isolate_->Throw(*error);
377 return EXCEPTION; 378 return EXCEPTION;
378 } 379 }
379 } 380 }
380 } 381 }
381 JSArray::EnsureSize(stack_, length + 1); 382 JSArray::EnsureSize(stack_, length + 1);
382 FixedArray::cast(stack_->elements())->set(length, *object); 383 FixedArray::cast(stack_->elements())->set(length, *object);
383 stack_->set_length(Smi::FromInt(length + 1)); 384 stack_->set_length(Smi::FromInt(length + 1));
384 return SUCCESS; 385 return SUCCESS;
385 } 386 }
386 387
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 SerializeString_<false, uint8_t>(object); 870 SerializeString_<false, uint8_t>(object);
870 } else { 871 } else {
871 SerializeString_<false, uc16>(object); 872 SerializeString_<false, uc16>(object);
872 } 873 }
873 } 874 }
874 } 875 }
875 876
876 } } // namespace v8::internal 877 } } // namespace v8::internal
877 878
878 #endif // V8_JSON_STRINGIFIER_H_ 879 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « src/json-parser.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698