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

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

Issue 396993004: Go to slow path when JSON.stringifying the global proxy. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 5 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 | « no previous file | no next file » | 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 if (deferred_string_key) SerializeDeferredKey(comma, key); 435 if (deferred_string_key) SerializeDeferredKey(comma, key);
436 return SerializeJSValue(Handle<JSValue>::cast(object)); 436 return SerializeJSValue(Handle<JSValue>::cast(object));
437 case JS_FUNCTION_TYPE: 437 case JS_FUNCTION_TYPE:
438 return UNCHANGED; 438 return UNCHANGED;
439 default: 439 default:
440 if (object->IsString()) { 440 if (object->IsString()) {
441 if (deferred_string_key) SerializeDeferredKey(comma, key); 441 if (deferred_string_key) SerializeDeferredKey(comma, key);
442 SerializeString(Handle<String>::cast(object)); 442 SerializeString(Handle<String>::cast(object));
443 return SUCCESS; 443 return SUCCESS;
444 } else if (object->IsJSObject()) { 444 } else if (object->IsJSObject()) {
445 if (object->IsAccessCheckNeeded()) break; 445 // Go to slow path for global proxy and objects requiring access checks.
446 if (object->IsAccessCheckNeeded() || object->IsJSGlobalProxy()) break;
446 if (deferred_string_key) SerializeDeferredKey(comma, key); 447 if (deferred_string_key) SerializeDeferredKey(comma, key);
447 return SerializeJSObject(Handle<JSObject>::cast(object)); 448 return SerializeJSObject(Handle<JSObject>::cast(object));
448 } 449 }
449 } 450 }
450 451
451 return SerializeGeneric(object, key, comma, deferred_string_key); 452 return SerializeGeneric(object, key, comma, deferred_string_key);
452 } 453 }
453 454
454 455
455 BasicJsonStringifier::Result BasicJsonStringifier::SerializeGeneric( 456 BasicJsonStringifier::Result BasicJsonStringifier::SerializeGeneric(
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 624 }
624 return SUCCESS; 625 return SUCCESS;
625 } 626 }
626 627
627 628
628 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSObject( 629 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSObject(
629 Handle<JSObject> object) { 630 Handle<JSObject> object) {
630 HandleScope handle_scope(isolate_); 631 HandleScope handle_scope(isolate_);
631 Result stack_push = StackPush(object); 632 Result stack_push = StackPush(object);
632 if (stack_push != SUCCESS) return stack_push; 633 if (stack_push != SUCCESS) return stack_push;
633 if (object->IsJSGlobalProxy()) { 634 ASSERT(!object->IsJSGlobalProxy() && !object->IsGlobalObject());
634 object = Handle<JSObject>(
635 JSObject::cast(object->GetPrototype()), isolate_);
636 ASSERT(object->IsGlobalObject());
637 }
638 635
639 Append('{'); 636 Append('{');
640 bool comma = false; 637 bool comma = false;
641 638
642 if (object->HasFastProperties() && 639 if (object->HasFastProperties() &&
643 !object->HasIndexedInterceptor() && 640 !object->HasIndexedInterceptor() &&
644 !object->HasNamedInterceptor() && 641 !object->HasNamedInterceptor() &&
645 object->elements()->length() == 0) { 642 object->elements()->length() == 0) {
646 Handle<Map> map(object->map()); 643 Handle<Map> map(object->map());
647 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { 644 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 SerializeString_<false, uint8_t>(object); 868 SerializeString_<false, uint8_t>(object);
872 } else { 869 } else {
873 SerializeString_<false, uc16>(object); 870 SerializeString_<false, uc16>(object);
874 } 871 }
875 } 872 }
876 } 873 }
877 874
878 } } // namespace v8::internal 875 } } // namespace v8::internal
879 876
880 #endif // V8_JSON_STRINGIFIER_H_ 877 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698