Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 kUint16Array = 'W', | 117 kUint16Array = 'W', |
| 118 kInt32Array = 'd', | 118 kInt32Array = 'd', |
| 119 kUint32Array = 'D', | 119 kUint32Array = 'D', |
| 120 kFloat32Array = 'f', | 120 kFloat32Array = 'f', |
| 121 kFloat64Array = 'F', | 121 kFloat64Array = 'F', |
| 122 kDataView = '?', | 122 kDataView = '?', |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 } // namespace | 125 } // namespace |
| 126 | 126 |
| 127 ValueSerializer::ValueSerializer(Isolate* isolate) | 127 ValueSerializer::ValueSerializer(Isolate* isolate, |
| 128 v8::ValueSerializer::Delegate* delegate) | |
| 128 : isolate_(isolate), | 129 : isolate_(isolate), |
| 130 delegate_(delegate), | |
| 129 zone_(isolate->allocator()), | 131 zone_(isolate->allocator()), |
| 130 id_map_(isolate->heap(), &zone_), | 132 id_map_(isolate->heap(), &zone_), |
| 131 array_buffer_transfer_map_(isolate->heap(), &zone_) {} | 133 array_buffer_transfer_map_(isolate->heap(), &zone_) {} |
| 132 | 134 |
| 133 ValueSerializer::~ValueSerializer() {} | 135 ValueSerializer::~ValueSerializer() {} |
| 134 | 136 |
| 135 void ValueSerializer::WriteHeader() { | 137 void ValueSerializer::WriteHeader() { |
| 136 WriteTag(SerializationTag::kVersion); | 138 WriteTag(SerializationTag::kVersion); |
| 137 WriteVarint(kLatestVersion); | 139 WriteVarint(kLatestVersion); |
| 138 } | 140 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 if (!WriteJSReceiver(buffer).FromMaybe(false)) return Nothing<bool>(); | 242 if (!WriteJSReceiver(buffer).FromMaybe(false)) return Nothing<bool>(); |
| 241 } | 243 } |
| 242 return WriteJSReceiver(view); | 244 return WriteJSReceiver(view); |
| 243 } | 245 } |
| 244 default: | 246 default: |
| 245 if (object->IsString()) { | 247 if (object->IsString()) { |
| 246 WriteString(Handle<String>::cast(object)); | 248 WriteString(Handle<String>::cast(object)); |
| 247 return Just(true); | 249 return Just(true); |
| 248 } else if (object->IsJSReceiver()) { | 250 } else if (object->IsJSReceiver()) { |
| 249 return WriteJSReceiver(Handle<JSReceiver>::cast(object)); | 251 return WriteJSReceiver(Handle<JSReceiver>::cast(object)); |
| 252 } else { | |
| 253 ThrowDataCloneError(MessageTemplate::kDataCloneError, object); | |
|
Jakob Kummerow
2016/09/02 10:20:28
I'm not sure about this case. UNIMPLEMENTED() cras
jbroman
2016/09/02 14:51:08
At the moment, this is the case that handles Symbo
| |
| 254 return Nothing<bool>(); | |
| 250 } | 255 } |
| 251 UNIMPLEMENTED(); | |
| 252 return Nothing<bool>(); | |
| 253 } | 256 } |
| 254 } | 257 } |
| 255 | 258 |
| 256 void ValueSerializer::WriteOddball(Oddball* oddball) { | 259 void ValueSerializer::WriteOddball(Oddball* oddball) { |
| 257 SerializationTag tag = SerializationTag::kUndefined; | 260 SerializationTag tag = SerializationTag::kUndefined; |
| 258 switch (oddball->kind()) { | 261 switch (oddball->kind()) { |
| 259 case Oddball::kUndefined: | 262 case Oddball::kUndefined: |
| 260 tag = SerializationTag::kUndefined; | 263 tag = SerializationTag::kUndefined; |
| 261 break; | 264 break; |
| 262 case Oddball::kFalse: | 265 case Oddball::kFalse: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 return Just(true); | 333 return Just(true); |
| 331 } | 334 } |
| 332 | 335 |
| 333 // Otherwise, allocate an ID for it. | 336 // Otherwise, allocate an ID for it. |
| 334 uint32_t id = next_id_++; | 337 uint32_t id = next_id_++; |
| 335 *id_map_entry = id + 1; | 338 *id_map_entry = id + 1; |
| 336 | 339 |
| 337 // Eliminate callable and exotic objects, which should not be serialized. | 340 // Eliminate callable and exotic objects, which should not be serialized. |
| 338 InstanceType instance_type = receiver->map()->instance_type(); | 341 InstanceType instance_type = receiver->map()->instance_type(); |
| 339 if (receiver->IsCallable() || instance_type <= LAST_SPECIAL_RECEIVER_TYPE) { | 342 if (receiver->IsCallable() || instance_type <= LAST_SPECIAL_RECEIVER_TYPE) { |
| 343 ThrowDataCloneError(MessageTemplate::kDataCloneError, receiver); | |
| 340 return Nothing<bool>(); | 344 return Nothing<bool>(); |
| 341 } | 345 } |
| 342 | 346 |
| 343 // If we are at the end of the stack, abort. This function may recurse. | 347 // If we are at the end of the stack, abort. This function may recurse. |
| 344 if (StackLimitCheck(isolate_).HasOverflowed()) return Nothing<bool>(); | 348 STACK_CHECK(isolate_, Nothing<bool>()); |
| 345 | 349 |
| 346 HandleScope scope(isolate_); | 350 HandleScope scope(isolate_); |
| 347 switch (instance_type) { | 351 switch (instance_type) { |
| 348 case JS_ARRAY_TYPE: | 352 case JS_ARRAY_TYPE: |
| 349 return WriteJSArray(Handle<JSArray>::cast(receiver)); | 353 return WriteJSArray(Handle<JSArray>::cast(receiver)); |
| 350 case JS_OBJECT_TYPE: | 354 case JS_OBJECT_TYPE: |
| 351 case JS_API_OBJECT_TYPE: | 355 case JS_API_OBJECT_TYPE: |
| 352 return WriteJSObject(Handle<JSObject>::cast(receiver)); | 356 return WriteJSObject(Handle<JSObject>::cast(receiver)); |
| 353 case JS_DATE_TYPE: | 357 case JS_DATE_TYPE: |
| 354 WriteJSDate(JSDate::cast(*receiver)); | 358 WriteJSDate(JSDate::cast(*receiver)); |
| 355 return Just(true); | 359 return Just(true); |
| 356 case JS_VALUE_TYPE: | 360 case JS_VALUE_TYPE: |
| 357 return WriteJSValue(Handle<JSValue>::cast(receiver)); | 361 return WriteJSValue(Handle<JSValue>::cast(receiver)); |
| 358 case JS_REGEXP_TYPE: | 362 case JS_REGEXP_TYPE: |
| 359 WriteJSRegExp(JSRegExp::cast(*receiver)); | 363 WriteJSRegExp(JSRegExp::cast(*receiver)); |
| 360 return Just(true); | 364 return Just(true); |
| 361 case JS_MAP_TYPE: | 365 case JS_MAP_TYPE: |
| 362 return WriteJSMap(Handle<JSMap>::cast(receiver)); | 366 return WriteJSMap(Handle<JSMap>::cast(receiver)); |
| 363 case JS_SET_TYPE: | 367 case JS_SET_TYPE: |
| 364 return WriteJSSet(Handle<JSSet>::cast(receiver)); | 368 return WriteJSSet(Handle<JSSet>::cast(receiver)); |
| 365 case JS_ARRAY_BUFFER_TYPE: | 369 case JS_ARRAY_BUFFER_TYPE: |
| 366 return WriteJSArrayBuffer(JSArrayBuffer::cast(*receiver)); | 370 return WriteJSArrayBuffer(JSArrayBuffer::cast(*receiver)); |
| 367 case JS_TYPED_ARRAY_TYPE: | 371 case JS_TYPED_ARRAY_TYPE: |
| 368 case JS_DATA_VIEW_TYPE: | 372 case JS_DATA_VIEW_TYPE: |
| 369 return WriteJSArrayBufferView(JSArrayBufferView::cast(*receiver)); | 373 return WriteJSArrayBufferView(JSArrayBufferView::cast(*receiver)); |
| 370 default: | 374 default: |
| 371 UNIMPLEMENTED(); | 375 ThrowDataCloneError(MessageTemplate::kDataCloneError, receiver); |
|
Jakob Kummerow
2016/09/02 10:20:28
same here
jbroman
2016/09/02 14:51:08
Similarly, there are a number of kinds of receiver
| |
| 372 break; | 376 return Nothing<bool>(); |
| 373 } | 377 } |
| 374 return Nothing<bool>(); | 378 return Nothing<bool>(); |
| 375 } | 379 } |
| 376 | 380 |
| 377 Maybe<bool> ValueSerializer::WriteJSObject(Handle<JSObject> object) { | 381 Maybe<bool> ValueSerializer::WriteJSObject(Handle<JSObject> object) { |
| 378 WriteTag(SerializationTag::kBeginJSObject); | 382 WriteTag(SerializationTag::kBeginJSObject); |
| 379 Handle<FixedArray> keys; | 383 Handle<FixedArray> keys; |
| 380 uint32_t properties_written; | 384 uint32_t properties_written; |
| 381 if (!KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, | 385 if (!KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, |
| 382 ENUMERABLE_STRINGS) | 386 ENUMERABLE_STRINGS) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 WriteTag(SerializationTag::kStringObject); | 476 WriteTag(SerializationTag::kStringObject); |
| 473 v8::Local<v8::String> api_string = | 477 v8::Local<v8::String> api_string = |
| 474 Utils::ToLocal(handle(String::cast(inner_value), isolate_)); | 478 Utils::ToLocal(handle(String::cast(inner_value), isolate_)); |
| 475 uint32_t utf8_length = api_string->Utf8Length(); | 479 uint32_t utf8_length = api_string->Utf8Length(); |
| 476 WriteVarint(utf8_length); | 480 WriteVarint(utf8_length); |
| 477 api_string->WriteUtf8(reinterpret_cast<char*>(ReserveRawBytes(utf8_length)), | 481 api_string->WriteUtf8(reinterpret_cast<char*>(ReserveRawBytes(utf8_length)), |
| 478 utf8_length, nullptr, | 482 utf8_length, nullptr, |
| 479 v8::String::NO_NULL_TERMINATION); | 483 v8::String::NO_NULL_TERMINATION); |
| 480 } else { | 484 } else { |
| 481 DCHECK(inner_value->IsSymbol()); | 485 DCHECK(inner_value->IsSymbol()); |
| 486 ThrowDataCloneError(MessageTemplate::kDataCloneError, value); | |
| 482 return Nothing<bool>(); | 487 return Nothing<bool>(); |
| 483 } | 488 } |
| 484 return Just(true); | 489 return Just(true); |
| 485 } | 490 } |
| 486 | 491 |
| 487 void ValueSerializer::WriteJSRegExp(JSRegExp* regexp) { | 492 void ValueSerializer::WriteJSRegExp(JSRegExp* regexp) { |
| 488 WriteTag(SerializationTag::kRegExp); | 493 WriteTag(SerializationTag::kRegExp); |
| 489 v8::Local<v8::String> api_string = | 494 v8::Local<v8::String> api_string = |
| 490 Utils::ToLocal(handle(regexp->Pattern(), isolate_)); | 495 Utils::ToLocal(handle(regexp->Pattern(), isolate_)); |
| 491 uint32_t utf8_length = api_string->Utf8Length(); | 496 uint32_t utf8_length = api_string->Utf8Length(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 uint32_t* transfer_entry = array_buffer_transfer_map_.Find(array_buffer); | 565 uint32_t* transfer_entry = array_buffer_transfer_map_.Find(array_buffer); |
| 561 if (transfer_entry) { | 566 if (transfer_entry) { |
| 562 DCHECK(array_buffer->was_neutered() || array_buffer->is_shared()); | 567 DCHECK(array_buffer->was_neutered() || array_buffer->is_shared()); |
| 563 WriteTag(array_buffer->is_shared() | 568 WriteTag(array_buffer->is_shared() |
| 564 ? SerializationTag::kSharedArrayBufferTransfer | 569 ? SerializationTag::kSharedArrayBufferTransfer |
| 565 : SerializationTag::kArrayBufferTransfer); | 570 : SerializationTag::kArrayBufferTransfer); |
| 566 WriteVarint(*transfer_entry); | 571 WriteVarint(*transfer_entry); |
| 567 return Just(true); | 572 return Just(true); |
| 568 } | 573 } |
| 569 | 574 |
| 570 if (array_buffer->is_shared()) return Nothing<bool>(); | 575 if (array_buffer->is_shared()) { |
| 571 if (array_buffer->was_neutered()) return Nothing<bool>(); | 576 ThrowDataCloneError( |
| 577 MessageTemplate::kDataCloneErrorSharedArrayBufferNotTransferred); | |
| 578 return Nothing<bool>(); | |
| 579 } | |
| 580 if (array_buffer->was_neutered()) { | |
| 581 ThrowDataCloneError(MessageTemplate::kDataCloneErrorNeuteredArrayBuffer); | |
| 582 return Nothing<bool>(); | |
| 583 } | |
| 572 double byte_length = array_buffer->byte_length()->Number(); | 584 double byte_length = array_buffer->byte_length()->Number(); |
| 573 if (byte_length > std::numeric_limits<uint32_t>::max()) { | 585 if (byte_length > std::numeric_limits<uint32_t>::max()) { |
| 586 ThrowDataCloneError(MessageTemplate::kDataCloneError, handle(array_buffer)); | |
| 574 return Nothing<bool>(); | 587 return Nothing<bool>(); |
| 575 } | 588 } |
| 576 WriteTag(SerializationTag::kArrayBuffer); | 589 WriteTag(SerializationTag::kArrayBuffer); |
| 577 WriteVarint<uint32_t>(byte_length); | 590 WriteVarint<uint32_t>(byte_length); |
| 578 WriteRawBytes(array_buffer->backing_store(), byte_length); | 591 WriteRawBytes(array_buffer->backing_store(), byte_length); |
| 579 return Just(true); | 592 return Just(true); |
| 580 } | 593 } |
| 581 | 594 |
| 582 Maybe<bool> ValueSerializer::WriteJSArrayBufferView(JSArrayBufferView* view) { | 595 Maybe<bool> ValueSerializer::WriteJSArrayBufferView(JSArrayBufferView* view) { |
| 583 WriteTag(SerializationTag::kArrayBufferView); | 596 WriteTag(SerializationTag::kArrayBufferView); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 if (!WriteObject(key).FromMaybe(false) || | 635 if (!WriteObject(key).FromMaybe(false) || |
| 623 !WriteObject(value).FromMaybe(false)) { | 636 !WriteObject(value).FromMaybe(false)) { |
| 624 return Nothing<uint32_t>(); | 637 return Nothing<uint32_t>(); |
| 625 } | 638 } |
| 626 | 639 |
| 627 properties_written++; | 640 properties_written++; |
| 628 } | 641 } |
| 629 return Just(properties_written); | 642 return Just(properties_written); |
| 630 } | 643 } |
| 631 | 644 |
| 645 void ValueSerializer::ThrowDataCloneError( | |
| 646 MessageTemplate::Template template_index) { | |
| 647 return ThrowDataCloneError(template_index, | |
| 648 isolate_->factory()->empty_string()); | |
| 649 } | |
| 650 | |
| 651 void ValueSerializer::ThrowDataCloneError( | |
| 652 MessageTemplate::Template template_index, Handle<Object> arg0) { | |
| 653 Handle<String> message = | |
| 654 MessageTemplate::FormatMessage(isolate_, template_index, arg0); | |
| 655 if (delegate_) { | |
| 656 delegate_->ThrowDataCloneError(Utils::ToLocal(message)); | |
| 657 } else { | |
| 658 isolate_->Throw( | |
| 659 *isolate_->factory()->NewError(isolate_->error_function(), message)); | |
| 660 } | |
| 661 } | |
| 662 | |
| 632 ValueDeserializer::ValueDeserializer(Isolate* isolate, | 663 ValueDeserializer::ValueDeserializer(Isolate* isolate, |
| 633 Vector<const uint8_t> data) | 664 Vector<const uint8_t> data) |
| 634 : isolate_(isolate), | 665 : isolate_(isolate), |
| 635 position_(data.start()), | 666 position_(data.start()), |
| 636 end_(data.start() + data.length()), | 667 end_(data.start() + data.length()), |
| 637 id_map_(Handle<SeededNumberDictionary>::cast( | 668 id_map_(Handle<SeededNumberDictionary>::cast( |
| 638 isolate->global_handles()->Create( | 669 isolate->global_handles()->Create( |
| 639 *SeededNumberDictionary::New(isolate, 0)))) {} | 670 *SeededNumberDictionary::New(isolate, 0)))) {} |
| 640 | 671 |
| 641 ValueDeserializer::~ValueDeserializer() { | 672 ValueDeserializer::~ValueDeserializer() { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 880 return MaybeHandle<String>(); | 911 return MaybeHandle<String>(); |
| 881 | 912 |
| 882 // Copy the bytes directly into the new string. | 913 // Copy the bytes directly into the new string. |
| 883 // Warning: this uses host endianness. | 914 // Warning: this uses host endianness. |
| 884 memcpy(string->GetChars(), bytes.begin(), bytes.length()); | 915 memcpy(string->GetChars(), bytes.begin(), bytes.length()); |
| 885 return string; | 916 return string; |
| 886 } | 917 } |
| 887 | 918 |
| 888 MaybeHandle<JSObject> ValueDeserializer::ReadJSObject() { | 919 MaybeHandle<JSObject> ValueDeserializer::ReadJSObject() { |
| 889 // If we are at the end of the stack, abort. This function may recurse. | 920 // If we are at the end of the stack, abort. This function may recurse. |
| 890 if (StackLimitCheck(isolate_).HasOverflowed()) return MaybeHandle<JSObject>(); | 921 STACK_CHECK(isolate_, MaybeHandle<JSObject>()); |
| 891 | 922 |
| 892 uint32_t id = next_id_++; | 923 uint32_t id = next_id_++; |
| 893 HandleScope scope(isolate_); | 924 HandleScope scope(isolate_); |
| 894 Handle<JSObject> object = | 925 Handle<JSObject> object = |
| 895 isolate_->factory()->NewJSObject(isolate_->object_function()); | 926 isolate_->factory()->NewJSObject(isolate_->object_function()); |
| 896 AddObjectWithID(id, object); | 927 AddObjectWithID(id, object); |
| 897 | 928 |
| 898 uint32_t num_properties; | 929 uint32_t num_properties; |
| 899 uint32_t expected_num_properties; | 930 uint32_t expected_num_properties; |
| 900 if (!ReadJSObjectProperties(object, SerializationTag::kEndJSObject) | 931 if (!ReadJSObjectProperties(object, SerializationTag::kEndJSObject) |
| 901 .To(&num_properties) || | 932 .To(&num_properties) || |
| 902 !ReadVarint<uint32_t>().To(&expected_num_properties) || | 933 !ReadVarint<uint32_t>().To(&expected_num_properties) || |
| 903 num_properties != expected_num_properties) { | 934 num_properties != expected_num_properties) { |
| 904 return MaybeHandle<JSObject>(); | 935 return MaybeHandle<JSObject>(); |
| 905 } | 936 } |
| 906 | 937 |
| 907 DCHECK(HasObjectWithID(id)); | 938 DCHECK(HasObjectWithID(id)); |
| 908 return scope.CloseAndEscape(object); | 939 return scope.CloseAndEscape(object); |
| 909 } | 940 } |
| 910 | 941 |
| 911 MaybeHandle<JSArray> ValueDeserializer::ReadSparseJSArray() { | 942 MaybeHandle<JSArray> ValueDeserializer::ReadSparseJSArray() { |
| 912 // If we are at the end of the stack, abort. This function may recurse. | 943 // If we are at the end of the stack, abort. This function may recurse. |
| 913 if (StackLimitCheck(isolate_).HasOverflowed()) return MaybeHandle<JSArray>(); | 944 STACK_CHECK(isolate_, MaybeHandle<JSArray>()); |
| 914 | 945 |
| 915 uint32_t length; | 946 uint32_t length; |
| 916 if (!ReadVarint<uint32_t>().To(&length)) return MaybeHandle<JSArray>(); | 947 if (!ReadVarint<uint32_t>().To(&length)) return MaybeHandle<JSArray>(); |
| 917 | 948 |
| 918 uint32_t id = next_id_++; | 949 uint32_t id = next_id_++; |
| 919 HandleScope scope(isolate_); | 950 HandleScope scope(isolate_); |
| 920 Handle<JSArray> array = isolate_->factory()->NewJSArray(0); | 951 Handle<JSArray> array = isolate_->factory()->NewJSArray(0); |
| 921 JSArray::SetLength(array, length); | 952 JSArray::SetLength(array, length); |
| 922 AddObjectWithID(id, array); | 953 AddObjectWithID(id, array); |
| 923 | 954 |
| 924 uint32_t num_properties; | 955 uint32_t num_properties; |
| 925 uint32_t expected_num_properties; | 956 uint32_t expected_num_properties; |
| 926 uint32_t expected_length; | 957 uint32_t expected_length; |
| 927 if (!ReadJSObjectProperties(array, SerializationTag::kEndSparseJSArray) | 958 if (!ReadJSObjectProperties(array, SerializationTag::kEndSparseJSArray) |
| 928 .To(&num_properties) || | 959 .To(&num_properties) || |
| 929 !ReadVarint<uint32_t>().To(&expected_num_properties) || | 960 !ReadVarint<uint32_t>().To(&expected_num_properties) || |
| 930 !ReadVarint<uint32_t>().To(&expected_length) || | 961 !ReadVarint<uint32_t>().To(&expected_length) || |
| 931 num_properties != expected_num_properties || length != expected_length) { | 962 num_properties != expected_num_properties || length != expected_length) { |
| 932 return MaybeHandle<JSArray>(); | 963 return MaybeHandle<JSArray>(); |
| 933 } | 964 } |
| 934 | 965 |
| 935 DCHECK(HasObjectWithID(id)); | 966 DCHECK(HasObjectWithID(id)); |
| 936 return scope.CloseAndEscape(array); | 967 return scope.CloseAndEscape(array); |
| 937 } | 968 } |
| 938 | 969 |
| 939 MaybeHandle<JSArray> ValueDeserializer::ReadDenseJSArray() { | 970 MaybeHandle<JSArray> ValueDeserializer::ReadDenseJSArray() { |
| 940 // If we are at the end of the stack, abort. This function may recurse. | 971 // If we are at the end of the stack, abort. This function may recurse. |
| 941 if (StackLimitCheck(isolate_).HasOverflowed()) return MaybeHandle<JSArray>(); | 972 STACK_CHECK(isolate_, MaybeHandle<JSArray>()); |
| 942 | 973 |
| 943 uint32_t length; | 974 uint32_t length; |
| 944 if (!ReadVarint<uint32_t>().To(&length)) return MaybeHandle<JSArray>(); | 975 if (!ReadVarint<uint32_t>().To(&length)) return MaybeHandle<JSArray>(); |
| 945 | 976 |
| 946 uint32_t id = next_id_++; | 977 uint32_t id = next_id_++; |
| 947 HandleScope scope(isolate_); | 978 HandleScope scope(isolate_); |
| 948 Handle<JSArray> array = isolate_->factory()->NewJSArray( | 979 Handle<JSArray> array = isolate_->factory()->NewJSArray( |
| 949 FAST_HOLEY_ELEMENTS, length, length, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 980 FAST_HOLEY_ELEMENTS, length, length, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
| 950 AddObjectWithID(id, array); | 981 AddObjectWithID(id, array); |
| 951 | 982 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1035 !JSRegExp::New(pattern, static_cast<JSRegExp::Flags>(raw_flags)) | 1066 !JSRegExp::New(pattern, static_cast<JSRegExp::Flags>(raw_flags)) |
| 1036 .ToHandle(®exp)) { | 1067 .ToHandle(®exp)) { |
| 1037 return MaybeHandle<JSRegExp>(); | 1068 return MaybeHandle<JSRegExp>(); |
| 1038 } | 1069 } |
| 1039 AddObjectWithID(id, regexp); | 1070 AddObjectWithID(id, regexp); |
| 1040 return regexp; | 1071 return regexp; |
| 1041 } | 1072 } |
| 1042 | 1073 |
| 1043 MaybeHandle<JSMap> ValueDeserializer::ReadJSMap() { | 1074 MaybeHandle<JSMap> ValueDeserializer::ReadJSMap() { |
| 1044 // If we are at the end of the stack, abort. This function may recurse. | 1075 // If we are at the end of the stack, abort. This function may recurse. |
| 1045 if (StackLimitCheck(isolate_).HasOverflowed()) return MaybeHandle<JSMap>(); | 1076 STACK_CHECK(isolate_, MaybeHandle<JSMap>()); |
| 1046 | 1077 |
| 1047 HandleScope scope(isolate_); | 1078 HandleScope scope(isolate_); |
| 1048 uint32_t id = next_id_++; | 1079 uint32_t id = next_id_++; |
| 1049 Handle<JSMap> map = isolate_->factory()->NewJSMap(); | 1080 Handle<JSMap> map = isolate_->factory()->NewJSMap(); |
| 1050 AddObjectWithID(id, map); | 1081 AddObjectWithID(id, map); |
| 1051 | 1082 |
| 1052 Handle<JSFunction> map_set = isolate_->map_set(); | 1083 Handle<JSFunction> map_set = isolate_->map_set(); |
| 1053 uint32_t length = 0; | 1084 uint32_t length = 0; |
| 1054 while (true) { | 1085 while (true) { |
| 1055 SerializationTag tag; | 1086 SerializationTag tag; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1072 if (!ReadVarint<uint32_t>().To(&expected_length) || | 1103 if (!ReadVarint<uint32_t>().To(&expected_length) || |
| 1073 length != expected_length) { | 1104 length != expected_length) { |
| 1074 return MaybeHandle<JSMap>(); | 1105 return MaybeHandle<JSMap>(); |
| 1075 } | 1106 } |
| 1076 DCHECK(HasObjectWithID(id)); | 1107 DCHECK(HasObjectWithID(id)); |
| 1077 return scope.CloseAndEscape(map); | 1108 return scope.CloseAndEscape(map); |
| 1078 } | 1109 } |
| 1079 | 1110 |
| 1080 MaybeHandle<JSSet> ValueDeserializer::ReadJSSet() { | 1111 MaybeHandle<JSSet> ValueDeserializer::ReadJSSet() { |
| 1081 // If we are at the end of the stack, abort. This function may recurse. | 1112 // If we are at the end of the stack, abort. This function may recurse. |
| 1082 if (StackLimitCheck(isolate_).HasOverflowed()) return MaybeHandle<JSSet>(); | 1113 STACK_CHECK(isolate_, MaybeHandle<JSSet>()); |
| 1083 | 1114 |
| 1084 HandleScope scope(isolate_); | 1115 HandleScope scope(isolate_); |
| 1085 uint32_t id = next_id_++; | 1116 uint32_t id = next_id_++; |
| 1086 Handle<JSSet> set = isolate_->factory()->NewJSSet(); | 1117 Handle<JSSet> set = isolate_->factory()->NewJSSet(); |
| 1087 AddObjectWithID(id, set); | 1118 AddObjectWithID(id, set); |
| 1088 Handle<JSFunction> set_add = isolate_->set_add(); | 1119 Handle<JSFunction> set_add = isolate_->set_add(); |
| 1089 uint32_t length = 0; | 1120 uint32_t length = 0; |
| 1090 while (true) { | 1121 while (true) { |
| 1091 SerializationTag tag; | 1122 SerializationTag tag; |
| 1092 if (!PeekTag().To(&tag)) return MaybeHandle<JSSet>(); | 1123 if (!PeekTag().To(&tag)) return MaybeHandle<JSSet>(); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1348 } | 1379 } |
| 1349 #endif | 1380 #endif |
| 1350 position_ = end_; | 1381 position_ = end_; |
| 1351 | 1382 |
| 1352 if (stack.size() != 1) return MaybeHandle<Object>(); | 1383 if (stack.size() != 1) return MaybeHandle<Object>(); |
| 1353 return scope.CloseAndEscape(stack[0]); | 1384 return scope.CloseAndEscape(stack[0]); |
| 1354 } | 1385 } |
| 1355 | 1386 |
| 1356 } // namespace internal | 1387 } // namespace internal |
| 1357 } // namespace v8 | 1388 } // namespace v8 |
| OLD | NEW |