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

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

Issue 10830131: Adding deopt info to code object. (Closed) Base URL: http://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
« no previous file with comments | « runtime/vm/code_descriptors.cc ('k') | runtime/vm/object.cc » ('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 #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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 kTokenStreamClass, 163 kTokenStreamClass,
164 kScriptClass, 164 kScriptClass,
165 kLibraryClass, 165 kLibraryClass,
166 kLibraryPrefixClass, 166 kLibraryPrefixClass,
167 kCodeClass, 167 kCodeClass,
168 kInstructionsClass, 168 kInstructionsClass,
169 kPcDescriptorsClass, 169 kPcDescriptorsClass,
170 kStackmapClass, 170 kStackmapClass,
171 kLocalVarDescriptorsClass, 171 kLocalVarDescriptorsClass,
172 kExceptionHandlersClass, 172 kExceptionHandlersClass,
173 kDeoptInfoClass,
173 kContextClass, 174 kContextClass,
174 kContextScopeClass, 175 kContextScopeClass,
175 kICDataClass, 176 kICDataClass,
176 kSubtypeTestCacheClass, 177 kSubtypeTestCacheClass,
177 kApiErrorClass, 178 kApiErrorClass,
178 kLanguageErrorClass, 179 kLanguageErrorClass,
179 kUnhandledExceptionClass, 180 kUnhandledExceptionClass,
180 kUnwindErrorClass, 181 kUnwindErrorClass,
181 kMaxId, 182 kMaxId,
182 kInvalidIndex = -1, 183 kInvalidIndex = -1,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 static RawClass* library_class() { return library_class_; } 303 static RawClass* library_class() { return library_class_; }
303 static RawClass* library_prefix_class() { return library_prefix_class_; } 304 static RawClass* library_prefix_class() { return library_prefix_class_; }
304 static RawClass* code_class() { return code_class_; } 305 static RawClass* code_class() { return code_class_; }
305 static RawClass* instructions_class() { return instructions_class_; } 306 static RawClass* instructions_class() { return instructions_class_; }
306 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; } 307 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; }
307 static RawClass* stackmap_class() { return stackmap_class_; } 308 static RawClass* stackmap_class() { return stackmap_class_; }
308 static RawClass* var_descriptors_class() { return var_descriptors_class_; } 309 static RawClass* var_descriptors_class() { return var_descriptors_class_; }
309 static RawClass* exception_handlers_class() { 310 static RawClass* exception_handlers_class() {
310 return exception_handlers_class_; 311 return exception_handlers_class_;
311 } 312 }
313 static RawClass* deopt_info_class() { return deopt_info_class_; }
312 static RawClass* context_class() { return context_class_; } 314 static RawClass* context_class() { return context_class_; }
313 static RawClass* context_scope_class() { return context_scope_class_; } 315 static RawClass* context_scope_class() { return context_scope_class_; }
314 static RawClass* api_error_class() { return api_error_class_; } 316 static RawClass* api_error_class() { return api_error_class_; }
315 static RawClass* language_error_class() { return language_error_class_; } 317 static RawClass* language_error_class() { return language_error_class_; }
316 static RawClass* unhandled_exception_class() { 318 static RawClass* unhandled_exception_class() {
317 return unhandled_exception_class_; 319 return unhandled_exception_class_;
318 } 320 }
319 static RawClass* unwind_error_class() { return unwind_error_class_; } 321 static RawClass* unwind_error_class() { return unwind_error_class_; }
320 static RawClass* icdata_class() { return icdata_class_; } 322 static RawClass* icdata_class() { return icdata_class_; }
321 static RawClass* subtypetestcache_class() { return subtypetestcache_class_; } 323 static RawClass* subtypetestcache_class() { return subtypetestcache_class_; }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 static RawClass* token_stream_class_; // Class of the TokenStream vm object. 435 static RawClass* token_stream_class_; // Class of the TokenStream vm object.
434 static RawClass* script_class_; // Class of the Script vm object. 436 static RawClass* script_class_; // Class of the Script vm object.
435 static RawClass* library_class_; // Class of the Library vm object. 437 static RawClass* library_class_; // Class of the Library vm object.
436 static RawClass* library_prefix_class_; // Class of Library prefix vm object. 438 static RawClass* library_prefix_class_; // Class of Library prefix vm object.
437 static RawClass* code_class_; // Class of the Code vm object. 439 static RawClass* code_class_; // Class of the Code vm object.
438 static RawClass* instructions_class_; // Class of the Instructions vm object. 440 static RawClass* instructions_class_; // Class of the Instructions vm object.
439 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. 441 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
440 static RawClass* stackmap_class_; // Class of Stackmap vm object. 442 static RawClass* stackmap_class_; // Class of Stackmap vm object.
441 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. 443 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors.
442 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. 444 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers.
445 static RawClass* deopt_info_class_; // Class of DeoptInfo.
443 static RawClass* context_class_; // Class of the Context vm object. 446 static RawClass* context_class_; // Class of the Context vm object.
444 static RawClass* context_scope_class_; // Class of ContextScope vm object. 447 static RawClass* context_scope_class_; // Class of ContextScope vm object.
445 static RawClass* icdata_class_; // Class of ICData. 448 static RawClass* icdata_class_; // Class of ICData.
446 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. 449 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache.
447 static RawClass* api_error_class_; // Class of ApiError. 450 static RawClass* api_error_class_; // Class of ApiError.
448 static RawClass* language_error_class_; // Class of LanguageError. 451 static RawClass* language_error_class_; // Class of LanguageError.
449 static RawClass* unhandled_exception_class_; // Class of UnhandledException. 452 static RawClass* unhandled_exception_class_; // Class of UnhandledException.
450 static RawClass* unwind_error_class_; // Class of UnwindError. 453 static RawClass* unwind_error_class_; // Class of UnwindError.
451 454
452 friend void ClassTable::Register(const Class& cls); 455 friend void ClassTable::Register(const Class& cls);
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 kNodeIdEntry, // AST node id. 2201 kNodeIdEntry, // AST node id.
2199 kTokenIndexEntry, // Token position in source of PC. 2202 kTokenIndexEntry, // Token position in source of PC.
2200 kTryIndexEntry, // Try block index of PC. 2203 kTryIndexEntry, // Try block index of PC.
2201 // We would potentially be adding other objects here like 2204 // We would potentially be adding other objects here like
2202 // pointer maps for optimized functions, local variables information etc. 2205 // pointer maps for optimized functions, local variables information etc.
2203 kNumberOfEntries 2206 kNumberOfEntries
2204 }; 2207 };
2205 2208
2206 public: 2209 public:
2207 enum Kind { 2210 enum Kind {
2208 kDeopt = 0, // Deoptimization cotinuation point. 2211 kDeopt = 0, // Deoptimization cotinuation point.
2209 kPatchCode, // Buffer for patching code entry. 2212 kDeoptIndex, // Index into deopt info array.
2210 kIcCall, // IC call. 2213 kPatchCode, // Buffer for patching code entry.
2211 kFuncCall, // Call to known target, e.g. static call, closure call. 2214 kIcCall, // IC call.
2212 kReturn, // Return from function. 2215 kFuncCall, // Call to known target, e.g. static call, closure call.
2216 kReturn, // Return from function.
2213 kOther 2217 kOther
2214 }; 2218 };
2215 2219
2216 intptr_t Length() const; 2220 intptr_t Length() const;
2217 2221
2218 uword PC(intptr_t index) const; 2222 uword PC(intptr_t index) const;
2219 PcDescriptors::Kind DescriptorKind(intptr_t index) const; 2223 PcDescriptors::Kind DescriptorKind(intptr_t index) const;
2220 const char* KindAsStr(intptr_t index) const; 2224 const char* KindAsStr(intptr_t index) const;
2221 intptr_t NodeId(intptr_t index) const; 2225 intptr_t NodeId(intptr_t index) const;
2222 intptr_t TokenIndex(intptr_t index) const; 2226 intptr_t TokenIndex(intptr_t index) const;
2223 intptr_t TryIndex(intptr_t index) const; 2227 intptr_t TryIndex(intptr_t index) const;
2228 // Index into the deopt-info array of Code object.
2229 intptr_t DeoptIndex(intptr_t index) const;
2224 2230
2225 void AddDescriptor(intptr_t index, 2231 void AddDescriptor(intptr_t index,
2226 uword pc, 2232 uword pc,
2227 PcDescriptors::Kind kind, 2233 PcDescriptors::Kind kind,
2228 intptr_t node_id, 2234 intptr_t node_id,
2229 intptr_t token_pos, 2235 intptr_t token_pos,
2230 intptr_t try_index) const { 2236 intptr_t try_index) const {
2231 SetPC(index, pc); 2237 SetPC(index, pc);
2232 SetKind(index, kind); 2238 SetKind(index, kind);
2233 SetNodeId(index, node_id); 2239 SetNodeId(index, node_id);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 ASSERT((index >=0) && (index < Length())); 2393 ASSERT((index >=0) && (index < Length()));
2388 intptr_t data_index = (index * kNumberOfEntries) + entry_offset; 2394 intptr_t data_index = (index * kNumberOfEntries) + entry_offset;
2389 return &raw_ptr()->data_[data_index]; 2395 return &raw_ptr()->data_[data_index];
2390 } 2396 }
2391 2397
2392 HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers, Object); 2398 HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers, Object);
2393 friend class Class; 2399 friend class Class;
2394 }; 2400 };
2395 2401
2396 2402
2403 // Holds deopt information at one deoptimization point. The information
2404 // is a list of DeoptInstr objects, specifying transformation information
2405 // for each slot in unoptimized frame(s).
2406 class DeoptInfo : public Object {
2407 private:
2408 // Describes the layout of deopt info data. The index of a deopt-info entry
2409 // is implicitly the target slot in which the value is written into.
2410 enum {
2411 kInstruction = 0,
2412 kFromIndex,
2413 kNumberOfEntries,
2414 };
2415
2416 public:
2417 intptr_t Length() const;
2418
2419 static RawDeoptInfo* New(intptr_t num_commands);
2420
2421 static const intptr_t kBytesPerElement = (kNumberOfEntries * kWordSize);
2422 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
2423
2424 static intptr_t InstanceSize() {
2425 ASSERT(sizeof(RawDeoptInfo) == OFFSET_OF(RawDeoptInfo, data_));
2426 return 0;
2427 }
2428
2429 static intptr_t InstanceSize(intptr_t len) {
2430 ASSERT(0 <= len && len <= kMaxElements);
2431 return RoundedAllocationSize(sizeof(RawDeoptInfo) +
2432 (len * kBytesPerElement));
2433 }
2434
2435 // 'index' corresponds to target, to-index.
2436 void SetAt(intptr_t index,
2437 intptr_t instr_kind,
2438 intptr_t from_index) const;
2439
2440 intptr_t Instruction(intptr_t index) const;
2441 intptr_t FromIndex(intptr_t index) const;
2442 intptr_t ToIndex(intptr_t index) const {
2443 return index;
2444 }
2445
2446 private:
2447 intptr_t* EntryAddr(intptr_t index, intptr_t entry_offset) const {
2448 ASSERT((index >=0) && (index < Length()));
2449 intptr_t data_index = (index * kNumberOfEntries) + entry_offset;
2450 return &raw_ptr()->data_[data_index];
2451 }
2452
2453 void SetLength(intptr_t value) const;
2454
2455 HEAP_OBJECT_IMPLEMENTATION(DeoptInfo, Object);
2456 friend class Class;
2457 };
2458
2459
2397 class Code : public Object { 2460 class Code : public Object {
2398 public: 2461 public:
2399 RawInstructions* instructions() const { return raw_ptr()->instructions_; } 2462 RawInstructions* instructions() const { return raw_ptr()->instructions_; }
2400 static intptr_t instructions_offset() { 2463 static intptr_t instructions_offset() {
2401 return OFFSET_OF(RawCode, instructions_); 2464 return OFFSET_OF(RawCode, instructions_);
2402 } 2465 }
2403 intptr_t pointer_offsets_length() const { 2466 intptr_t pointer_offsets_length() const {
2404 return raw_ptr()->pointer_offsets_length_; 2467 return raw_ptr()->pointer_offsets_length_;
2405 } 2468 }
2406 bool is_optimized() const { 2469 bool is_optimized() const {
(...skipping 11 matching lines...) Expand all
2418 return instr.size(); 2481 return instr.size();
2419 } 2482 }
2420 2483
2421 RawPcDescriptors* pc_descriptors() const { 2484 RawPcDescriptors* pc_descriptors() const {
2422 return raw_ptr()->pc_descriptors_; 2485 return raw_ptr()->pc_descriptors_;
2423 } 2486 }
2424 void set_pc_descriptors(const PcDescriptors& descriptors) const { 2487 void set_pc_descriptors(const PcDescriptors& descriptors) const {
2425 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw()); 2488 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw());
2426 } 2489 }
2427 2490
2491 // Array of DeoptInfo objects.
2492 RawArray* deopt_info_array() const {
2493 return raw_ptr()->deopt_info_array_;
2494 }
2495 void set_deopt_info_array(const Array& array) const;
2496
2497 RawArray* object_table() const {
2498 return raw_ptr()->object_table_;
2499 }
2500 void set_object_table(const Array& array) const;
2501
2428 RawArray* stackmaps() const { 2502 RawArray* stackmaps() const {
2429 return raw_ptr()->stackmaps_; 2503 return raw_ptr()->stackmaps_;
2430 } 2504 }
2431 void set_stackmaps(const Array& maps) const; 2505 void set_stackmaps(const Array& maps) const;
2432 RawStackmap* GetStackmap(uword pc, Array* stackmaps, Stackmap* map) const; 2506 RawStackmap* GetStackmap(uword pc, Array* stackmaps, Stackmap* map) const;
2433 2507
2434 class Comments : public ZoneAllocated { 2508 class Comments : public ZoneAllocated {
2435 public: 2509 public:
2436 static Comments& New(intptr_t count); 2510 static Comments& New(intptr_t count);
2437 2511
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2510 intptr_t GetTokenIndexOfPC(uword pc) const; 2584 intptr_t GetTokenIndexOfPC(uword pc) const;
2511 2585
2512 // Find pc of patch code buffer. Return 0 if not found. 2586 // Find pc of patch code buffer. Return 0 if not found.
2513 uword GetPatchCodePc() const; 2587 uword GetPatchCodePc() const;
2514 2588
2515 uword GetDeoptPcAtNodeId(intptr_t node_id) const; 2589 uword GetDeoptPcAtNodeId(intptr_t node_id) const;
2516 uword GetTypeTestAtNodeId(intptr_t node_id) const; 2590 uword GetTypeTestAtNodeId(intptr_t node_id) const;
2517 2591
2518 // Returns true if there is an object in the code between 'start_offset' 2592 // Returns true if there is an object in the code between 'start_offset'
2519 // (inclusive) and 'end_offset' (exclusive). 2593 // (inclusive) and 'end_offset' (exclusive).
2520 bool ObjectExistInArea(intptr_t start_offest, intptr_t end_offset) const; 2594 bool ObjectExistsInArea(intptr_t start_offest, intptr_t end_offset) const;
2521 2595
2522 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n]. 2596 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n].
2523 // Returns the maximum id found. 2597 // Returns the maximum id found.
2524 intptr_t ExtractIcDataArraysAtCalls( 2598 intptr_t ExtractIcDataArraysAtCalls(
2525 GrowableArray<intptr_t>* node_ids, 2599 GrowableArray<intptr_t>* node_ids,
2526 const GrowableObjectArray& ic_data_objs) const; 2600 const GrowableObjectArray& ic_data_objs) const;
2527 2601
2528 private: 2602 private:
2529 // An object finder visitor interface. 2603 // An object finder visitor interface.
2530 class FindRawCodeVisitor : public FindObjectVisitor { 2604 class FindRawCodeVisitor : public FindObjectVisitor {
(...skipping 2838 matching lines...) Expand 10 before | Expand all | Expand 10 after
5369 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5443 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5370 return false; 5444 return false;
5371 } 5445 }
5372 } 5446 }
5373 return true; 5447 return true;
5374 } 5448 }
5375 5449
5376 } // namespace dart 5450 } // namespace dart
5377 5451
5378 #endif // VM_OBJECT_H_ 5452 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698