OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/native_entry.h" | 5 #include "vm/native_entry.h" |
6 #include "vm/object.h" | 6 #include "vm/object.h" |
7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
8 #include "vm/snapshot.h" | 8 #include "vm/snapshot.h" |
9 #include "vm/stub_code.h" | 9 #include "vm/stub_code.h" |
10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
(...skipping 3495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3506 visitor.VisitPointers(from(), to()); | 3506 visitor.VisitPointers(from(), to()); |
3507 } else { | 3507 } else { |
3508 // Stacktraces are not allowed in other snapshot forms. | 3508 // Stacktraces are not allowed in other snapshot forms. |
3509 writer->SetWriteException(Exceptions::kArgument, | 3509 writer->SetWriteException(Exceptions::kArgument, |
3510 "Illegal argument in isolate message" | 3510 "Illegal argument in isolate message" |
3511 " : (object is a stacktrace)"); | 3511 " : (object is a stacktrace)"); |
3512 } | 3512 } |
3513 } | 3513 } |
3514 | 3514 |
3515 | 3515 |
3516 RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader, | 3516 RawRegExp* RegExp::ReadFrom(SnapshotReader* reader, |
3517 intptr_t object_id, | 3517 intptr_t object_id, |
3518 intptr_t tags, | 3518 intptr_t tags, |
3519 Snapshot::Kind kind, | 3519 Snapshot::Kind kind, |
3520 bool as_reference) { | 3520 bool as_reference) { |
3521 ASSERT(reader != NULL); | 3521 ASSERT(reader != NULL); |
3522 | 3522 |
3523 // Allocate JSRegExp object. | 3523 // Allocate RegExp object. |
3524 JSRegExp& regex = JSRegExp::ZoneHandle(reader->zone(), NEW_OBJECT(JSRegExp)); | 3524 RegExp& regex = RegExp::ZoneHandle(reader->zone(), NEW_OBJECT(RegExp)); |
3525 reader->AddBackRef(object_id, ®ex, kIsDeserialized); | 3525 reader->AddBackRef(object_id, ®ex, kIsDeserialized); |
3526 | 3526 |
3527 // Read and Set all the other fields. | 3527 // Read and Set all the other fields. |
3528 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, | 3528 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, |
3529 reader->ReadAsSmi()); | 3529 reader->ReadAsSmi()); |
3530 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); | 3530 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
3531 regex.set_pattern(*reader->StringHandle()); | 3531 regex.set_pattern(*reader->StringHandle()); |
3532 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, | 3532 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, |
3533 reader->Read<int32_t>()); | 3533 reader->Read<int32_t>()); |
3534 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, | 3534 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, |
3535 reader->Read<int8_t>()); | 3535 reader->Read<int8_t>()); |
3536 | 3536 |
3537 // TODO(18854): Need to implement a way of recreating the irrexp functions. | 3537 // TODO(18854): Need to implement a way of recreating the irrexp functions. |
3538 const Function& no_function = Function::Handle(reader->zone()); | 3538 const Function& no_function = Function::Handle(reader->zone()); |
3539 regex.set_function(kOneByteStringCid, no_function); | 3539 regex.set_function(kOneByteStringCid, no_function); |
3540 regex.set_function(kTwoByteStringCid, no_function); | 3540 regex.set_function(kTwoByteStringCid, no_function); |
3541 regex.set_function(kExternalOneByteStringCid, no_function); | 3541 regex.set_function(kExternalOneByteStringCid, no_function); |
3542 regex.set_function(kExternalTwoByteStringCid, no_function); | 3542 regex.set_function(kExternalTwoByteStringCid, no_function); |
3543 | 3543 |
3544 const TypedData& no_bytecode = TypedData::Handle(reader->zone()); | 3544 const TypedData& no_bytecode = TypedData::Handle(reader->zone()); |
3545 regex.set_bytecode(true, no_bytecode); | 3545 regex.set_bytecode(true, no_bytecode); |
3546 regex.set_bytecode(false, no_bytecode); | 3546 regex.set_bytecode(false, no_bytecode); |
3547 | 3547 |
3548 return regex.raw(); | 3548 return regex.raw(); |
3549 } | 3549 } |
3550 | 3550 |
3551 | 3551 |
3552 void RawJSRegExp::WriteTo(SnapshotWriter* writer, | 3552 void RawRegExp::WriteTo(SnapshotWriter* writer, |
3553 intptr_t object_id, | 3553 intptr_t object_id, |
3554 Snapshot::Kind kind, | 3554 Snapshot::Kind kind, |
3555 bool as_reference) { | 3555 bool as_reference) { |
3556 ASSERT(writer != NULL); | 3556 ASSERT(writer != NULL); |
3557 | 3557 |
3558 // Write out the serialization header value for this object. | 3558 // Write out the serialization header value for this object. |
3559 writer->WriteInlinedObjectHeader(object_id); | 3559 writer->WriteInlinedObjectHeader(object_id); |
3560 | 3560 |
3561 // Write out the class and tags information. | 3561 // Write out the class and tags information. |
3562 writer->WriteIndexedObject(kJSRegExpCid); | 3562 writer->WriteIndexedObject(kRegExpCid); |
3563 writer->WriteTags(writer->GetObjectTags(this)); | 3563 writer->WriteTags(writer->GetObjectTags(this)); |
3564 | 3564 |
3565 // Write out all the other fields. | 3565 // Write out all the other fields. |
3566 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 3566 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
3567 writer->WriteObjectImpl(ptr()->pattern_, kAsInlinedObject); | 3567 writer->WriteObjectImpl(ptr()->pattern_, kAsInlinedObject); |
3568 writer->Write<int32_t>(ptr()->num_registers_); | 3568 writer->Write<int32_t>(ptr()->num_registers_); |
3569 writer->Write<int8_t>(ptr()->type_flags_); | 3569 writer->Write<int8_t>(ptr()->type_flags_); |
3570 } | 3570 } |
3571 | 3571 |
3572 | 3572 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3653 // We do not allow objects with native fields in an isolate message. | 3653 // We do not allow objects with native fields in an isolate message. |
3654 writer->SetWriteException(Exceptions::kArgument, | 3654 writer->SetWriteException(Exceptions::kArgument, |
3655 "Illegal argument in isolate message" | 3655 "Illegal argument in isolate message" |
3656 " : (object is a UserTag)"); | 3656 " : (object is a UserTag)"); |
3657 } else { | 3657 } else { |
3658 UNREACHABLE(); | 3658 UNREACHABLE(); |
3659 } | 3659 } |
3660 } | 3660 } |
3661 | 3661 |
3662 } // namespace dart | 3662 } // namespace dart |
OLD | NEW |