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

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

Issue 1294583006: Clean up native context slots and add new ones. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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/json.js ('k') | src/math.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 // 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/conversions.h" 8 #include "src/conversions.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/string-builder.h" 10 #include "src/string-builder.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 351
352 return SerializeGeneric(object, key, comma, deferred_string_key); 352 return SerializeGeneric(object, key, comma, deferred_string_key);
353 } 353 }
354 354
355 355
356 BasicJsonStringifier::Result BasicJsonStringifier::SerializeGeneric( 356 BasicJsonStringifier::Result BasicJsonStringifier::SerializeGeneric(
357 Handle<Object> object, 357 Handle<Object> object,
358 Handle<Object> key, 358 Handle<Object> key,
359 bool deferred_comma, 359 bool deferred_comma,
360 bool deferred_key) { 360 bool deferred_key) {
361 Handle<JSObject> builtins(isolate_->native_context()->builtins(), isolate_); 361 Handle<JSFunction> fun = isolate_->json_serialize_adapter();
362 Handle<JSFunction> builtin = Handle<JSFunction>::cast(
363 Object::GetProperty(isolate_, builtins, "$jsonSerializeAdapter")
364 .ToHandleChecked());
365
366 Handle<Object> argv[] = { key, object }; 362 Handle<Object> argv[] = { key, object };
367 Handle<Object> result; 363 Handle<Object> result;
368 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 364 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
369 isolate_, result, 365 isolate_, result, Execution::Call(isolate_, fun, object, 2, argv),
370 Execution::Call(isolate_, builtin, object, 2, argv),
371 EXCEPTION); 366 EXCEPTION);
372 if (result->IsUndefined()) return UNCHANGED; 367 if (result->IsUndefined()) return UNCHANGED;
373 if (deferred_key) { 368 if (deferred_key) {
374 if (key->IsSmi()) key = factory()->NumberToString(key); 369 if (key->IsSmi()) key = factory()->NumberToString(key);
375 SerializeDeferredKey(deferred_comma, key); 370 SerializeDeferredKey(deferred_comma, key);
376 } 371 }
377 372
378 builder_.AppendString(Handle<String>::cast(result)); 373 builder_.AppendString(Handle<String>::cast(result));
379 return SUCCESS; 374 return SUCCESS;
380 } 375 }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 SerializeString_<uint8_t, uc16>(object); 670 SerializeString_<uint8_t, uc16>(object);
676 } else { 671 } else {
677 SerializeString_<uc16, uc16>(object); 672 SerializeString_<uc16, uc16>(object);
678 } 673 }
679 } 674 }
680 } 675 }
681 676
682 } } // namespace v8::internal 677 } } // namespace v8::internal
683 678
684 #endif // V8_JSON_STRINGIFIER_H_ 679 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « src/json.js ('k') | src/math.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698