Chromium Code Reviews| 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 #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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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. | |
|
siva
2012/08/02 16:57:37
You should also mention here that the index of the
| |
| 2409 enum { | |
| 2410 kInstruction = 0, | |
| 2411 kFromIndex, | |
| 2412 kNumberOfEntries, | |
| 2413 }; | |
| 2414 | |
| 2415 public: | |
| 2416 intptr_t Length() const; | |
| 2417 | |
| 2418 static RawDeoptInfo* New(intptr_t num_commands); | |
| 2419 | |
| 2420 static const intptr_t kBytesPerElement = (kNumberOfEntries * kWordSize); | |
| 2421 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | |
| 2422 | |
| 2423 static intptr_t InstanceSize() { | |
| 2424 ASSERT(sizeof(RawDeoptInfo) == OFFSET_OF(RawDeoptInfo, data_)); | |
| 2425 return 0; | |
| 2426 } | |
| 2427 | |
| 2428 static intptr_t InstanceSize(intptr_t len) { | |
| 2429 ASSERT(0 <= len && len <= kMaxElements); | |
| 2430 return RoundedAllocationSize(sizeof(RawDeoptInfo) + | |
| 2431 (len * kBytesPerElement)); | |
| 2432 } | |
| 2433 | |
| 2434 // 'index' corresponds to target, to-index. | |
|
siva
2012/08/02 16:57:37
We have one deopt_info array per code object and w
srdjan
2012/08/02 17:51:44
Discussed offline. There is another level of indir
| |
| 2435 void SetAt(intptr_t index, | |
| 2436 intptr_t instr_kind, | |
| 2437 intptr_t from_index) const; | |
| 2438 | |
| 2439 intptr_t Instruction(intptr_t index) const; | |
| 2440 intptr_t FromIndex(intptr_t index) const; | |
| 2441 | |
| 2442 private: | |
| 2443 intptr_t* EntryAddr(intptr_t index, intptr_t entry_offset) const { | |
| 2444 ASSERT((index >=0) && (index < Length())); | |
| 2445 intptr_t data_index = (index * kNumberOfEntries) + entry_offset; | |
| 2446 return &raw_ptr()->data_[data_index]; | |
| 2447 } | |
| 2448 | |
| 2449 void SetLength(intptr_t value) const; | |
| 2450 | |
| 2451 HEAP_OBJECT_IMPLEMENTATION(DeoptInfo, Object); | |
| 2452 friend class Class; | |
| 2453 }; | |
| 2454 | |
| 2455 | |
| 2397 class Code : public Object { | 2456 class Code : public Object { |
| 2398 public: | 2457 public: |
| 2399 RawInstructions* instructions() const { return raw_ptr()->instructions_; } | 2458 RawInstructions* instructions() const { return raw_ptr()->instructions_; } |
| 2400 static intptr_t instructions_offset() { | 2459 static intptr_t instructions_offset() { |
| 2401 return OFFSET_OF(RawCode, instructions_); | 2460 return OFFSET_OF(RawCode, instructions_); |
| 2402 } | 2461 } |
| 2403 intptr_t pointer_offsets_length() const { | 2462 intptr_t pointer_offsets_length() const { |
| 2404 return raw_ptr()->pointer_offsets_length_; | 2463 return raw_ptr()->pointer_offsets_length_; |
| 2405 } | 2464 } |
| 2406 bool is_optimized() const { | 2465 bool is_optimized() const { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2418 return instr.size(); | 2477 return instr.size(); |
| 2419 } | 2478 } |
| 2420 | 2479 |
| 2421 RawPcDescriptors* pc_descriptors() const { | 2480 RawPcDescriptors* pc_descriptors() const { |
| 2422 return raw_ptr()->pc_descriptors_; | 2481 return raw_ptr()->pc_descriptors_; |
| 2423 } | 2482 } |
| 2424 void set_pc_descriptors(const PcDescriptors& descriptors) const { | 2483 void set_pc_descriptors(const PcDescriptors& descriptors) const { |
| 2425 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw()); | 2484 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw()); |
| 2426 } | 2485 } |
| 2427 | 2486 |
| 2487 // Array of DeoptInfo objects. | |
| 2488 RawArray* deopt_info_array() const { | |
| 2489 return raw_ptr()->deopt_info_array_; | |
| 2490 } | |
| 2491 void set_deopt_info_array(const Array& array) const; | |
| 2492 | |
| 2493 RawArray* object_table() const { | |
| 2494 return raw_ptr()->object_table_; | |
| 2495 } | |
| 2496 void set_object_table(const Array& array) const; | |
| 2497 | |
| 2428 RawArray* stackmaps() const { | 2498 RawArray* stackmaps() const { |
| 2429 return raw_ptr()->stackmaps_; | 2499 return raw_ptr()->stackmaps_; |
| 2430 } | 2500 } |
| 2431 void set_stackmaps(const Array& maps) const; | 2501 void set_stackmaps(const Array& maps) const; |
| 2432 RawStackmap* GetStackmap(uword pc, Array* stackmaps, Stackmap* map) const; | 2502 RawStackmap* GetStackmap(uword pc, Array* stackmaps, Stackmap* map) const; |
| 2433 | 2503 |
| 2434 class Comments : public ZoneAllocated { | 2504 class Comments : public ZoneAllocated { |
| 2435 public: | 2505 public: |
| 2436 static Comments& New(intptr_t count); | 2506 static Comments& New(intptr_t count); |
| 2437 | 2507 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2510 intptr_t GetTokenIndexOfPC(uword pc) const; | 2580 intptr_t GetTokenIndexOfPC(uword pc) const; |
| 2511 | 2581 |
| 2512 // Find pc of patch code buffer. Return 0 if not found. | 2582 // Find pc of patch code buffer. Return 0 if not found. |
| 2513 uword GetPatchCodePc() const; | 2583 uword GetPatchCodePc() const; |
| 2514 | 2584 |
| 2515 uword GetDeoptPcAtNodeId(intptr_t node_id) const; | 2585 uword GetDeoptPcAtNodeId(intptr_t node_id) const; |
| 2516 uword GetTypeTestAtNodeId(intptr_t node_id) const; | 2586 uword GetTypeTestAtNodeId(intptr_t node_id) const; |
| 2517 | 2587 |
| 2518 // Returns true if there is an object in the code between 'start_offset' | 2588 // Returns true if there is an object in the code between 'start_offset' |
| 2519 // (inclusive) and 'end_offset' (exclusive). | 2589 // (inclusive) and 'end_offset' (exclusive). |
| 2520 bool ObjectExistInArea(intptr_t start_offest, intptr_t end_offset) const; | 2590 bool ObjectExistsInArea(intptr_t start_offest, intptr_t end_offset) const; |
| 2521 | 2591 |
| 2522 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n]. | 2592 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n]. |
| 2523 // Returns the maximum id found. | 2593 // Returns the maximum id found. |
| 2524 intptr_t ExtractIcDataArraysAtCalls( | 2594 intptr_t ExtractIcDataArraysAtCalls( |
| 2525 GrowableArray<intptr_t>* node_ids, | 2595 GrowableArray<intptr_t>* node_ids, |
| 2526 const GrowableObjectArray& ic_data_objs) const; | 2596 const GrowableObjectArray& ic_data_objs) const; |
| 2527 | 2597 |
| 2528 private: | 2598 private: |
| 2529 // An object finder visitor interface. | 2599 // An object finder visitor interface. |
| 2530 class FindRawCodeVisitor : public FindObjectVisitor { | 2600 class FindRawCodeVisitor : public FindObjectVisitor { |
| (...skipping 2838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5369 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5439 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| 5370 return false; | 5440 return false; |
| 5371 } | 5441 } |
| 5372 } | 5442 } |
| 5373 return true; | 5443 return true; |
| 5374 } | 5444 } |
| 5375 | 5445 |
| 5376 } // namespace dart | 5446 } // namespace dart |
| 5377 | 5447 |
| 5378 #endif // VM_OBJECT_H_ | 5448 #endif // VM_OBJECT_H_ |
| OLD | NEW |