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

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

Issue 11366087: Reduce stack frame size in JSON.stringify. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 JSObject::cast(object->GetPrototype()), isolate_); 560 JSObject::cast(object->GetPrototype()), isolate_);
561 ASSERT(object->IsGlobalObject()); 561 ASSERT(object->IsGlobalObject());
562 } 562 }
563 563
564 Append('{'); 564 Append('{');
565 bool comma = false; 565 bool comma = false;
566 566
567 if (object->HasFastProperties() && 567 if (object->HasFastProperties() &&
568 !object->HasIndexedInterceptor() && 568 !object->HasIndexedInterceptor() &&
569 !object->HasNamedInterceptor() && 569 !object->HasNamedInterceptor() &&
570 object->elements() == isolate_->heap()->empty_fixed_array()) { 570 object->elements()->length() == 0) {
571 Handle<DescriptorArray> descs(
572 object->map()->instance_descriptors(), isolate_);
573 int num_desc = object->map()->NumberOfOwnDescriptors();
574 Handle<Map> map(object->map()); 571 Handle<Map> map(object->map());
575 bool map_changed = false; 572 int num_desc = map->NumberOfOwnDescriptors();
576 for (int i = 0; i < num_desc; i++) { 573 for (int i = 0; i < num_desc; i++) {
577 Handle<String> key(descs->GetKey(i), isolate_); 574 Handle<String> key(map->instance_descriptors()->GetKey(i), isolate_);
578 PropertyDetails details = descs->GetDetails(i); 575 PropertyDetails details = map->instance_descriptors()->GetDetails(i);
579 if (details.IsDontEnum() || details.IsDeleted()) continue; 576 if (details.IsDontEnum() || details.IsDeleted()) continue;
580 Handle<Object> property; 577 Handle<Object> property;
581 if (details.type() == FIELD && !map_changed) { 578 if (details.type() == FIELD && *map == object->map()) {
582 property = Handle<Object>( 579 property = Handle<Object>(
583 object->FastPropertyAt(descs->GetFieldIndex(i)), isolate_); 580 object->FastPropertyAt(
581 map->instance_descriptors()->GetFieldIndex(i)),
582 isolate_);
584 } else { 583 } else {
585 property = GetProperty(object, key); 584 property = GetProperty(object, key);
585 if (property.is_null()) return EXCEPTION;
586 } 586 }
587 if (property.is_null()) return EXCEPTION;
588 Result result = SerializeProperty(property, comma, key); 587 Result result = SerializeProperty(property, comma, key);
589 if (!comma && result == SUCCESS) comma = true; 588 if (!comma && result == SUCCESS) comma = true;
590 if (result >= EXCEPTION) return result; 589 if (result >= EXCEPTION) return result;
591 if (*map != object->map()) map_changed = true;
592 } 590 }
593 } else { 591 } else {
594 bool has_exception = false; 592 bool has_exception = false;
595 Handle<FixedArray> contents = 593 Handle<FixedArray> contents =
596 GetKeysInFixedArrayFor(object, LOCAL_ONLY, &has_exception); 594 GetKeysInFixedArrayFor(object, LOCAL_ONLY, &has_exception);
597 if (has_exception) return EXCEPTION; 595 if (has_exception) return EXCEPTION;
598 596
599 for (int i = 0; i < contents->length(); i++) { 597 for (int i = 0; i < contents->length(); i++) {
600 Object* key = contents->get(i); 598 Object* key = contents->get(i);
601 Handle<String> key_handle; 599 Handle<String> key_handle;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 SerializeString_<false, char>(flat.ToAsciiVector(), object); 793 SerializeString_<false, char>(flat.ToAsciiVector(), object);
796 } else { 794 } else {
797 SerializeString_<false, uc16>(flat.ToUC16Vector(), object); 795 SerializeString_<false, uc16>(flat.ToUC16Vector(), object);
798 } 796 }
799 } 797 }
800 } 798 }
801 799
802 } } // namespace v8::internal 800 } } // namespace v8::internal
803 801
804 #endif // V8_JSON_STRINGIFIER_H_ 802 #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