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

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

Issue 2674613002: Improve ValueSerializer perf regression after 96635558 (Closed)
Patch Set: Created 3 years, 10 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 void ValueSerializer::WriteRawBytes(const void* source, size_t length) { 225 void ValueSerializer::WriteRawBytes(const void* source, size_t length) {
226 uint8_t* dest; 226 uint8_t* dest;
227 if (ReserveRawBytes(length).To(&dest)) { 227 if (ReserveRawBytes(length).To(&dest)) {
228 memcpy(dest, source, length); 228 memcpy(dest, source, length);
229 } 229 }
230 } 230 }
231 231
232 Maybe<uint8_t*> ValueSerializer::ReserveRawBytes(size_t bytes) { 232 Maybe<uint8_t*> ValueSerializer::ReserveRawBytes(size_t bytes) {
233 size_t old_size = buffer_size_; 233 size_t old_size = buffer_size_;
234 size_t new_size = old_size + bytes; 234 size_t new_size = old_size + bytes;
235 if (new_size > buffer_capacity_) { 235 if (V8_UNLIKELY(new_size > buffer_capacity_)) {
236 bool ok; 236 bool ok;
237 if (!ExpandBuffer(new_size).To(&ok)) { 237 if (!ExpandBuffer(new_size).To(&ok)) {
238 return Nothing<uint8_t*>(); 238 return Nothing<uint8_t*>();
239 } 239 }
240 } 240 }
241 buffer_size_ = new_size; 241 buffer_size_ = new_size;
242 return Just(&buffer_[old_size]); 242 return Just(&buffer_[old_size]);
243 } 243 }
244 244
245 Maybe<bool> ValueSerializer::ExpandBuffer(size_t required_capacity) { 245 Maybe<bool> ValueSerializer::ExpandBuffer(size_t required_capacity) {
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 if (stack.size() != 1) { 1934 if (stack.size() != 1) {
1935 isolate_->Throw(*isolate_->factory()->NewError( 1935 isolate_->Throw(*isolate_->factory()->NewError(
1936 MessageTemplate::kDataCloneDeserializationError)); 1936 MessageTemplate::kDataCloneDeserializationError));
1937 return MaybeHandle<Object>(); 1937 return MaybeHandle<Object>();
1938 } 1938 }
1939 return scope.CloseAndEscape(stack[0]); 1939 return scope.CloseAndEscape(stack[0]);
1940 } 1940 }
1941 1941
1942 } // namespace internal 1942 } // namespace internal
1943 } // namespace v8 1943 } // 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