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

Unified Diff: src/runtime.cc

Issue 7977001: Added ability to lock strings to prevent their representation or encoding from changing. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: More tweaks. Created 9 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 side-by-side diff with in-line comments
Download patch
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 2b79bff320a465201c15a1f8776d592b213b4a42..46b01d8a78f75b2b3cdd42c9d19cf88cc149cc0a 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -9051,13 +9051,22 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) {
ASSERT_EQ(1, args.length());
CONVERT_ARG_CHECKED(String, source, 0);
- source = Handle<String>(source->TryFlattenGetString());
- // Optimized fast case where we only have ascii characters.
+ source = FlattenGetString(source);
Rico 2011/09/23 07:06:52 As discussed offline, please change comment in han
Lasse Reichstein 2011/09/23 09:54:39 Done.
+ ASSERT(!source->IsConsString());
+ ASSERT(!source->IsSlicedString());
Handle<Object> result;
- if (source->IsSeqAsciiString()) {
- result = JsonParser<true>::Parse(source);
- } else {
- result = JsonParser<false>::Parse(source);
+ {
+ StringLock lock_representation(source);
+ if (source->IsSeqAsciiString()) {
+ result = JsonParser<SeqAsciiString>::Parse(source);
+ } else if (source->IsExternalTwoByteString()) {
+ result = JsonParser<ExternalTwoByteString>::Parse(source);
+ } else if (source->IsSeqTwoByteString()) {
+ result = JsonParser<SeqTwoByteString>::Parse(source);
+ } else {
+ ASSERT(source->IsExternalAsciiString());
+ result = JsonParser<ExternalAsciiString>::Parse(source);
+ }
}
if (result.is_null()) {
// Syntax error or stack overflow in scanner.

Powered by Google App Engine
This is Rietveld 408576698