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

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

Issue 10837303: Make stackmaps store their actual length. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 2349
2350 2350
2351 class Stackmap : public Object { 2351 class Stackmap : public Object {
2352 public: 2352 public:
2353 static const intptr_t kNoMaximum = -1; 2353 static const intptr_t kNoMaximum = -1;
2354 static const intptr_t kNoMinimum = -1; 2354 static const intptr_t kNoMinimum = -1;
2355 2355
2356 bool IsObject(intptr_t index) const { 2356 bool IsObject(intptr_t index) const {
2357 return InRange(index) && GetBit(index); 2357 return InRange(index) && GetBit(index);
2358 } 2358 }
2359
2360 RawCode* Code() const { return raw_ptr()->code_; }
2361 void SetCode(const dart::Code& code) const;
2362
2363 intptr_t Length() const { return raw_ptr()->length_; }
2364
2359 uword PC() const { return raw_ptr()->pc_; } 2365 uword PC() const { return raw_ptr()->pc_; }
2360 void SetPC(uword value) const { raw_ptr()->pc_ = value; } 2366 void SetPC(uword value) const { raw_ptr()->pc_ = value; }
2361 2367
2362 RawCode* GetCode() const { return raw_ptr()->code_; }
2363 void SetCode(const Code& code) const;
2364
2365 // Return the index of the highest stack slot that has an object.
2366 intptr_t MaximumBitIndex() const { return raw_ptr()->max_set_bit_index_; }
2367
2368 // Return the index of the lowest stack slot that has an object.
2369 intptr_t MinimumBitIndex() const { return raw_ptr()->min_set_bit_index_; }
2370
2371 static const intptr_t kMaxLengthInBytes = kSmiMax; 2368 static const intptr_t kMaxLengthInBytes = kSmiMax;
2372 2369
2373 static intptr_t InstanceSize() { 2370 static intptr_t InstanceSize() {
2374 ASSERT(sizeof(RawStackmap) == OFFSET_OF(RawStackmap, data_)); 2371 ASSERT(sizeof(RawStackmap) == OFFSET_OF(RawStackmap, data_));
2375 return 0; 2372 return 0;
2376 } 2373 }
2377 static intptr_t InstanceSize(intptr_t length_in_bytes) { 2374 static intptr_t InstanceSize(intptr_t length) {
2378 ASSERT(length_in_bytes >= 0); 2375 ASSERT(length >= 0);
2379 ASSERT(length_in_bytes <= kMaxLengthInBytes); 2376 // The stackmap payload is in an array of bytes.
2380 return RoundedAllocationSize(sizeof(RawStackmap) + length_in_bytes); 2377 intptr_t payload_size =
2378 Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte;
2379 return RoundedAllocationSize(sizeof(RawStackmap) + payload_size);
2381 } 2380 }
2382 static RawStackmap* New(intptr_t pc_offset, 2381 static RawStackmap* New(intptr_t pc_offset,
2383 intptr_t length_in_bits, 2382 intptr_t length,
2384 BitmapBuilder* bmap); 2383 BitmapBuilder* bmap);
2385 2384
2386 private: 2385 private:
2387 inline intptr_t SizeInBits() const; 2386 void SetLength(intptr_t length) const { raw_ptr()->length_ = length; }
2388 2387
2389 void SetMinBitIndex(intptr_t value) const { 2388 bool InRange(intptr_t index) const { return index < Length(); }
2390 raw_ptr()->min_set_bit_index_ = value;
2391 }
2392 void SetMaxBitIndex(intptr_t value) const {
2393 raw_ptr()->max_set_bit_index_ = value;
2394 }
2395
2396 bool InRange(intptr_t index) const { return index < SizeInBits(); }
2397 2389
2398 bool GetBit(intptr_t bit_index) const; 2390 bool GetBit(intptr_t bit_index) const;
2399 void SetBit(intptr_t bit_index, bool value) const; 2391 void SetBit(intptr_t bit_index, bool value) const;
2400 2392
2401 void set_bitmap_size_in_bytes(intptr_t value) const;
2402
2403 HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); 2393 HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object);
2404 friend class BitmapBuilder; 2394 friend class BitmapBuilder;
2405 friend class Class; 2395 friend class Class;
2406 }; 2396 };
2407 2397
2408 2398
2409 class ExceptionHandlers : public Object { 2399 class ExceptionHandlers : public Object {
2410 private: 2400 private:
2411 // Describes the layout of exception handler data. 2401 // Describes the layout of exception handler data.
2412 enum { 2402 enum {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 } 2519 }
2530 intptr_t pointer_offsets_length() const { 2520 intptr_t pointer_offsets_length() const {
2531 return raw_ptr()->pointer_offsets_length_; 2521 return raw_ptr()->pointer_offsets_length_;
2532 } 2522 }
2533 bool is_optimized() const { 2523 bool is_optimized() const {
2534 return (raw_ptr()->is_optimized_ == 1); 2524 return (raw_ptr()->is_optimized_ == 1);
2535 } 2525 }
2536 void set_is_optimized(bool value) const { 2526 void set_is_optimized(bool value) const {
2537 raw_ptr()->is_optimized_ = value ? 1 : 0; 2527 raw_ptr()->is_optimized_ = value ? 1 : 0;
2538 } 2528 }
2539 intptr_t spill_slot_count() const {
Kevin Millikin (Google) 2012/08/17 09:07:43 This is no longer used, and it's easy to add back
2540 return raw_ptr()->spill_slot_count_;
2541 }
2542 void set_spill_slot_count(intptr_t count) const {
2543 raw_ptr()->spill_slot_count_ = count;
2544 }
2545 2529
2546 uword EntryPoint() const { 2530 uword EntryPoint() const {
2547 const Instructions& instr = Instructions::Handle(instructions()); 2531 const Instructions& instr = Instructions::Handle(instructions());
2548 return instr.EntryPoint(); 2532 return instr.EntryPoint();
2549 } 2533 }
2550 intptr_t Size() const { 2534 intptr_t Size() const {
2551 const Instructions& instr = Instructions::Handle(instructions()); 2535 const Instructions& instr = Instructions::Handle(instructions());
2552 return instr.size(); 2536 return instr.size();
2553 } 2537 }
2554 2538
(...skipping 2958 matching lines...) Expand 10 before | Expand all | Expand 10 after
5513 intptr_t TokenStream::Length() const { 5497 intptr_t TokenStream::Length() const {
5514 return Smi::Value(raw_ptr()->length_); 5498 return Smi::Value(raw_ptr()->length_);
5515 } 5499 }
5516 5500
5517 5501
5518 void Context::SetAt(intptr_t index, const Instance& value) const { 5502 void Context::SetAt(intptr_t index, const Instance& value) const {
5519 StorePointer(InstanceAddr(index), value.raw()); 5503 StorePointer(InstanceAddr(index), value.raw());
5520 } 5504 }
5521 5505
5522 5506
5523 intptr_t Stackmap::SizeInBits() const {
5524 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte);
5525 }
5526
5527
5528 bool String::Equals(const String& str) const { 5507 bool String::Equals(const String& str) const {
5529 if (raw() == str.raw()) { 5508 if (raw() == str.raw()) {
5530 return true; // Both handles point to the same raw instance. 5509 return true; // Both handles point to the same raw instance.
5531 } 5510 }
5532 if (str.IsNull()) { 5511 if (str.IsNull()) {
5533 return false; 5512 return false;
5534 } 5513 }
5535 return Equals(str, 0, str.Length()); 5514 return Equals(str, 0, str.Length());
5536 } 5515 }
5537 5516
(...skipping 12 matching lines...) Expand all
5550 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5529 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5551 return false; 5530 return false;
5552 } 5531 }
5553 } 5532 }
5554 return true; 5533 return true;
5555 } 5534 }
5556 5535
5557 } // namespace dart 5536 } // namespace dart
5558 5537
5559 #endif // VM_OBJECT_H_ 5538 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698