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

Unified Diff: src/json-stringifier.cc

Issue 2026563002: [json] implement InternalizeJSONProperty in C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/json-parser.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/json-stringifier.cc
diff --git a/src/json-stringifier.cc b/src/json-stringifier.cc
index b7059d6f110482ec9a8d06466a2a7114840e984b..27712cdd50831c8ebcffe3e6f5e3f51840a01df8 100644
--- a/src/json-stringifier.cc
+++ b/src/json-stringifier.cc
@@ -533,33 +533,20 @@ JsonStringifier::Result JsonStringifier::SerializeJSReceiverSlow(
if (contents.is_null()) {
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate_, contents,
- KeyAccumulator::GetKeys(object, OWN_ONLY, ENUMERABLE_STRINGS),
+ KeyAccumulator::GetKeys(object, OWN_ONLY, ENUMERABLE_STRINGS,
+ CONVERT_TO_STRING),
EXCEPTION);
}
builder_.AppendCharacter('{');
Indent();
bool comma = false;
for (int i = 0; i < contents->length(); i++) {
- Object* key = contents->get(i);
- Handle<String> key_handle;
- MaybeHandle<Object> maybe_property;
- if (key->IsString()) {
- key_handle = Handle<String>(String::cast(key), isolate_);
- maybe_property = Object::GetPropertyOrElement(object, key_handle);
- } else {
- DCHECK(key->IsNumber());
- key_handle = factory()->NumberToString(Handle<Object>(key, isolate_));
- if (key->IsSmi()) {
- maybe_property =
- JSReceiver::GetElement(isolate_, object, Smi::cast(key)->value());
- } else {
- maybe_property = Object::GetPropertyOrElement(object, key_handle);
- }
- }
+ Handle<String> key(String::cast(contents->get(i)));
Camillo Bruni 2016/05/30 14:25:20 nit: pass in the isolate_ directly
Handle<Object> property;
- ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate_, property, maybe_property,
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate_, property,
+ Object::GetPropertyOrElement(object, key),
EXCEPTION);
- Result result = SerializeProperty(property, comma, key_handle);
+ Result result = SerializeProperty(property, comma, key);
if (!comma && result == SUCCESS) comma = true;
if (result == EXCEPTION) return result;
}
@@ -571,6 +558,7 @@ JsonStringifier::Result JsonStringifier::SerializeJSReceiverSlow(
JsonStringifier::Result JsonStringifier::SerializeJSProxy(
Handle<JSProxy> object) {
+ HandleScope scope(isolate_);
Result stack_push = StackPush(object);
if (stack_push != SUCCESS) return stack_push;
Maybe<bool> is_array = Object::IsArray(object);
« no previous file with comments | « src/json-parser.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698