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

Side by Side Diff: runtime/vm/object.cc

Issue 13093012: More cleanup in preparation for removing support for dart:scalarlist in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 4960 matching lines...) Expand 10 before | Expand all | Expand 10 after
4971 RawArray* TokenStream::TokenObjects() const { 4971 RawArray* TokenStream::TokenObjects() const {
4972 return raw_ptr()->token_objects_; 4972 return raw_ptr()->token_objects_;
4973 } 4973 }
4974 4974
4975 4975
4976 void TokenStream::SetTokenObjects(const Array& value) const { 4976 void TokenStream::SetTokenObjects(const Array& value) const {
4977 StorePointer(&raw_ptr()->token_objects_, value.raw()); 4977 StorePointer(&raw_ptr()->token_objects_, value.raw());
4978 } 4978 }
4979 4979
4980 4980
4981 RawExternalUint8Array* TokenStream::GetStream() const { 4981 RawExternalTypedData* TokenStream::GetStream() const {
4982 return raw_ptr()->stream_; 4982 return raw_ptr()->stream_;
4983 } 4983 }
4984 4984
4985 4985
4986 void TokenStream::SetStream(const ExternalUint8Array& value) const { 4986 void TokenStream::SetStream(const ExternalTypedData& value) const {
4987 StorePointer(&raw_ptr()->stream_, value.raw()); 4987 StorePointer(&raw_ptr()->stream_, value.raw());
4988 } 4988 }
4989 4989
4990 4990
4991 void TokenStream::DataFinalizer(Dart_Handle handle, void *peer) { 4991 void TokenStream::DataFinalizer(Dart_Handle handle, void *peer) {
4992 ASSERT(peer != NULL); 4992 ASSERT(peer != NULL);
4993 ::free(peer); 4993 ::free(peer);
4994 DeleteWeakPersistentHandle(handle); 4994 DeleteWeakPersistentHandle(handle);
4995 } 4995 }
4996 4996
4997 4997
4998 RawString* TokenStream::PrivateKey() const { 4998 RawString* TokenStream::PrivateKey() const {
4999 return raw_ptr()->private_key_; 4999 return raw_ptr()->private_key_;
5000 } 5000 }
5001 5001
5002 5002
5003 void TokenStream::SetPrivateKey(const String& value) const { 5003 void TokenStream::SetPrivateKey(const String& value) const {
5004 StorePointer(&raw_ptr()->private_key_, value.raw()); 5004 StorePointer(&raw_ptr()->private_key_, value.raw());
5005 } 5005 }
5006 5006
5007 5007
5008 RawString* TokenStream::GenerateSource() const { 5008 RawString* TokenStream::GenerateSource() const {
5009 Iterator iterator(*this, 0); 5009 Iterator iterator(*this, 0);
5010 const ExternalUint8Array& data = ExternalUint8Array::Handle(GetStream()); 5010 const ExternalTypedData& data = ExternalTypedData::Handle(GetStream());
5011 const GrowableObjectArray& literals = 5011 const GrowableObjectArray& literals =
5012 GrowableObjectArray::Handle(GrowableObjectArray::New(data.Length())); 5012 GrowableObjectArray::Handle(GrowableObjectArray::New(data.Length()));
5013 const String& private_key = String::Handle(PrivateKey()); 5013 const String& private_key = String::Handle(PrivateKey());
5014 intptr_t private_len = private_key.Length(); 5014 intptr_t private_len = private_key.Length();
5015 5015
5016 Token::Kind curr = iterator.CurrentTokenKind(); 5016 Token::Kind curr = iterator.CurrentTokenKind();
5017 Token::Kind prev = Token::kILLEGAL; 5017 Token::Kind prev = Token::kILLEGAL;
5018 // Handles used in the loop. 5018 // Handles used in the loop.
5019 Object& obj = Object::Handle(); 5019 Object& obj = Object::Handle();
5020 String& literal = String::Handle(); 5020 String& literal = String::Handle();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
5182 } 5182 }
5183 5183
5184 5184
5185 RawTokenStream* TokenStream::New(intptr_t len) { 5185 RawTokenStream* TokenStream::New(intptr_t len) {
5186 if (len < 0 || len > kMaxElements) { 5186 if (len < 0 || len > kMaxElements) {
5187 // This should be caught before we reach here. 5187 // This should be caught before we reach here.
5188 FATAL1("Fatal error in TokenStream::New: invalid len %"Pd"\n", len); 5188 FATAL1("Fatal error in TokenStream::New: invalid len %"Pd"\n", len);
5189 } 5189 }
5190 uint8_t* data = reinterpret_cast<uint8_t*>(::malloc(len)); 5190 uint8_t* data = reinterpret_cast<uint8_t*>(::malloc(len));
5191 ASSERT(data != NULL); 5191 ASSERT(data != NULL);
5192 const ExternalUint8Array& stream = ExternalUint8Array::Handle( 5192 const ExternalTypedData& stream = ExternalTypedData::Handle(
5193 ExternalUint8Array::New(data, len, Heap::kOld)); 5193 ExternalTypedData::New(kExternalTypedDataUint8ArrayCid,
5194 data, len, Heap::kOld));
5194 stream.AddFinalizer(data, DataFinalizer); 5195 stream.AddFinalizer(data, DataFinalizer);
5195 const TokenStream& result = TokenStream::Handle(TokenStream::New()); 5196 const TokenStream& result = TokenStream::Handle(TokenStream::New());
5196 result.SetStream(stream); 5197 result.SetStream(stream);
5197 return result.raw(); 5198 return result.raw();
5198 } 5199 }
5199 5200
5200 5201
5201 // Helper class for creation of compressed token stream data. 5202 // Helper class for creation of compressed token stream data.
5202 class CompressedTokenStreamData : public ValueObject { 5203 class CompressedTokenStreamData : public ValueObject {
5203 public: 5204 public:
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
5356 ASSERT(token.kind < Token::kNumTokens); 5357 ASSERT(token.kind < Token::kNumTokens);
5357 data.AddSimpleToken(token.kind); 5358 data.AddSimpleToken(token.kind);
5358 } 5359 }
5359 } 5360 }
5360 if (FLAG_compiler_stats) { 5361 if (FLAG_compiler_stats) {
5361 CompilerStats::num_tokens_total += len; 5362 CompilerStats::num_tokens_total += len;
5362 } 5363 }
5363 data.AddSimpleToken(Token::kEOS); // End of stream. 5364 data.AddSimpleToken(Token::kEOS); // End of stream.
5364 5365
5365 // Create and setup the token stream object. 5366 // Create and setup the token stream object.
5366 const ExternalUint8Array& stream = ExternalUint8Array::Handle( 5367 const ExternalTypedData& stream = ExternalTypedData::Handle(
5367 ExternalUint8Array::New(data.GetStream(), data.Length(), Heap::kOld)); 5368 ExternalTypedData::New(kExternalTypedDataUint8ArrayCid,
5369 data.GetStream(), data.Length(), Heap::kOld));
5368 stream.AddFinalizer(data.GetStream(), DataFinalizer); 5370 stream.AddFinalizer(data.GetStream(), DataFinalizer);
5369 const TokenStream& result = TokenStream::Handle(New()); 5371 const TokenStream& result = TokenStream::Handle(New());
5370 result.SetPrivateKey(private_key); 5372 result.SetPrivateKey(private_key);
5371 { 5373 {
5372 NoGCScope no_gc; 5374 NoGCScope no_gc;
5373 result.SetStream(stream); 5375 result.SetStream(stream);
5374 const Array& tokens = Array::Handle(Array::MakeArray(data.TokenObjects())); 5376 const Array& tokens = Array::Handle(Array::MakeArray(data.TokenObjects()));
5375 result.SetTokenObjects(tokens); 5377 result.SetTokenObjects(tokens);
5376 } 5378 }
5377 return result.raw(); 5379 return result.raw();
5378 } 5380 }
5379 5381
5380 5382
5381 const char* TokenStream::ToCString() const { 5383 const char* TokenStream::ToCString() const {
5382 return "TokenStream"; 5384 return "TokenStream";
5383 } 5385 }
5384 5386
5385 5387
5386 TokenStream::Iterator::Iterator(const TokenStream& tokens, intptr_t token_pos) 5388 TokenStream::Iterator::Iterator(const TokenStream& tokens, intptr_t token_pos)
5387 : tokens_(TokenStream::Handle(tokens.raw())), 5389 : tokens_(TokenStream::Handle(tokens.raw())),
5388 data_(ExternalUint8Array::Handle(tokens.GetStream())), 5390 data_(ExternalTypedData::Handle(tokens.GetStream())),
5389 stream_(data_.ByteAddr(0), data_.Length()), 5391 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()),
5390 token_objects_(Array::Handle(tokens.TokenObjects())), 5392 token_objects_(Array::Handle(tokens.TokenObjects())),
5391 obj_(Object::Handle()), 5393 obj_(Object::Handle()),
5392 cur_token_pos_(token_pos), 5394 cur_token_pos_(token_pos),
5393 cur_token_kind_(Token::kILLEGAL), 5395 cur_token_kind_(Token::kILLEGAL),
5394 cur_token_obj_index_(-1) { 5396 cur_token_obj_index_(-1) {
5395 SetCurrentPosition(token_pos); 5397 SetCurrentPosition(token_pos);
5396 } 5398 }
5397 5399
5398 5400
5399 void TokenStream::Iterator::SetStream(const TokenStream& tokens, 5401 void TokenStream::Iterator::SetStream(const TokenStream& tokens,
5400 intptr_t token_pos) { 5402 intptr_t token_pos) {
5401 tokens_ = tokens.raw(); 5403 tokens_ = tokens.raw();
5402 data_ = tokens.GetStream(); 5404 data_ = tokens.GetStream();
5403 stream_.SetStream(data_.ByteAddr(0), data_.Length()); 5405 stream_.SetStream(reinterpret_cast<uint8_t*>(data_.DataAddr(0)),
5406 data_.Length());
5404 token_objects_ = tokens.TokenObjects(); 5407 token_objects_ = tokens.TokenObjects();
5405 obj_ = Object::null(); 5408 obj_ = Object::null();
5406 cur_token_pos_ = token_pos; 5409 cur_token_pos_ = token_pos;
5407 cur_token_kind_ = Token::kILLEGAL; 5410 cur_token_kind_ = Token::kILLEGAL;
5408 cur_token_obj_index_ = -1; 5411 cur_token_obj_index_ = -1;
5409 SetCurrentPosition(token_pos); 5412 SetCurrentPosition(token_pos);
5410 } 5413 }
5411 5414
5412 5415
5413 bool TokenStream::Iterator::IsValid() const { 5416 bool TokenStream::Iterator::IsValid() const {
(...skipping 8262 matching lines...) Expand 10 before | Expand all | Expand 10 after
13676 } 13679 }
13677 return result.raw(); 13680 return result.raw();
13678 } 13681 }
13679 13682
13680 13683
13681 const char* WeakProperty::ToCString() const { 13684 const char* WeakProperty::ToCString() const {
13682 return "_WeakProperty"; 13685 return "_WeakProperty";
13683 } 13686 }
13684 13687
13685 } // namespace dart 13688 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698