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

Side by Side Diff: src/value-serializer.cc

Issue 2784423002: ValueSerializer: add kOneByteString to expected key fast path. (Closed)
Patch Set: Created 3 years, 8 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 | « 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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #include "src/value-serializer.h" 5 #include "src/value-serializer.h"
6 6
7 #include <type_traits> 7 #include <type_traits>
8 8
9 #include "src/base/logging.h" 9 #include "src/base/logging.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 position_ = original_position; 1254 position_ = original_position;
1255 return false; 1255 return false;
1256 } 1256 }
1257 1257
1258 expected = String::Flatten(expected); 1258 expected = String::Flatten(expected);
1259 DisallowHeapAllocation no_gc; 1259 DisallowHeapAllocation no_gc;
1260 String::FlatContent flat = expected->GetFlatContent(); 1260 String::FlatContent flat = expected->GetFlatContent();
1261 1261
1262 // If the bytes are verbatim what is in the flattened string, then the string 1262 // If the bytes are verbatim what is in the flattened string, then the string
1263 // is successfully consumed. 1263 // is successfully consumed.
1264 if (tag == SerializationTag::kUtf8String && flat.IsOneByte()) { 1264 if (tag == SerializationTag::kOneByteString && flat.IsOneByte()) {
1265 Vector<const uint8_t> chars = flat.ToOneByteVector(); 1265 Vector<const uint8_t> chars = flat.ToOneByteVector();
1266 if (byte_length == static_cast<size_t>(chars.length()) && 1266 if (byte_length == static_cast<size_t>(chars.length()) &&
1267 String::IsAscii(chars.begin(), chars.length()) &&
1268 memcmp(bytes.begin(), chars.begin(), byte_length) == 0) { 1267 memcmp(bytes.begin(), chars.begin(), byte_length) == 0) {
1269 return true; 1268 return true;
1270 } 1269 }
1271 } else if (tag == SerializationTag::kTwoByteString && flat.IsTwoByte()) { 1270 } else if (tag == SerializationTag::kTwoByteString && flat.IsTwoByte()) {
1272 Vector<const uc16> chars = flat.ToUC16Vector(); 1271 Vector<const uc16> chars = flat.ToUC16Vector();
1273 if (byte_length == static_cast<unsigned>(chars.length()) * sizeof(uc16) && 1272 if (byte_length == static_cast<unsigned>(chars.length()) * sizeof(uc16) &&
1274 memcmp(bytes.begin(), chars.begin(), byte_length) == 0) { 1273 memcmp(bytes.begin(), chars.begin(), byte_length) == 0) {
1275 return true; 1274 return true;
1276 } 1275 }
1276 } else if (tag == SerializationTag::kUtf8String && flat.IsOneByte()) {
1277 Vector<const uint8_t> chars = flat.ToOneByteVector();
1278 if (byte_length == static_cast<size_t>(chars.length()) &&
1279 String::IsAscii(chars.begin(), chars.length()) &&
1280 memcmp(bytes.begin(), chars.begin(), byte_length) == 0) {
1281 return true;
1282 }
1277 } 1283 }
1278 1284
1279 position_ = original_position; 1285 position_ = original_position;
1280 return false; 1286 return false;
1281 } 1287 }
1282 1288
1283 MaybeHandle<JSObject> ValueDeserializer::ReadJSObject() { 1289 MaybeHandle<JSObject> ValueDeserializer::ReadJSObject() {
1284 // If we are at the end of the stack, abort. This function may recurse. 1290 // If we are at the end of the stack, abort. This function may recurse.
1285 STACK_CHECK(isolate_, MaybeHandle<JSObject>()); 1291 STACK_CHECK(isolate_, MaybeHandle<JSObject>());
1286 1292
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 if (stack.size() != 1) { 2015 if (stack.size() != 1) {
2010 isolate_->Throw(*isolate_->factory()->NewError( 2016 isolate_->Throw(*isolate_->factory()->NewError(
2011 MessageTemplate::kDataCloneDeserializationError)); 2017 MessageTemplate::kDataCloneDeserializationError));
2012 return MaybeHandle<Object>(); 2018 return MaybeHandle<Object>();
2013 } 2019 }
2014 return scope.CloseAndEscape(stack[0]); 2020 return scope.CloseAndEscape(stack[0]);
2015 } 2021 }
2016 2022
2017 } // namespace internal 2023 } // namespace internal
2018 } // namespace v8 2024 } // namespace v8
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