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

Side by Side Diff: src/objects.h

Issue 101853003: Cache optimized code for OSR. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments, fixed a bug. Created 7 years 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2941 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 2952
2953 // Copy a sub array from the receiver to dest. 2953 // Copy a sub array from the receiver to dest.
2954 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); 2954 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len);
2955 2955
2956 // Garbage collection support. 2956 // Garbage collection support.
2957 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } 2957 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; }
2958 2958
2959 // Code Generation support. 2959 // Code Generation support.
2960 static int OffsetOfElementAt(int index) { return SizeFor(index); } 2960 static int OffsetOfElementAt(int index) { return SizeFor(index); }
2961 2961
2962 // Garbage collection support.
2963 Object** RawFieldOfElementAt(int index) {
2964 return HeapObject::RawField(this, OffsetOfElementAt(index));
2965 }
2966
2962 // Casting. 2967 // Casting.
2963 static inline FixedArray* cast(Object* obj); 2968 static inline FixedArray* cast(Object* obj);
2964 2969
2965 // Maximal allowed size, in bytes, of a single FixedArray. 2970 // Maximal allowed size, in bytes, of a single FixedArray.
2966 // Prevents overflowing size computations, as well as extreme memory 2971 // Prevents overflowing size computations, as well as extreme memory
2967 // consumption. 2972 // consumption.
2968 static const int kMaxSize = 128 * MB * kPointerSize; 2973 static const int kMaxSize = 128 * MB * kPointerSize;
2969 // Maximally allowed length of a FixedArray. 2974 // Maximally allowed length of a FixedArray.
2970 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; 2975 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize;
2971 2976
(...skipping 3558 matching lines...) Expand 10 before | Expand all | Expand 10 after
6530 DECL_ACCESSORS(name, Object) 6535 DECL_ACCESSORS(name, Object)
6531 6536
6532 // [code]: Function code. 6537 // [code]: Function code.
6533 DECL_ACCESSORS(code, Code) 6538 DECL_ACCESSORS(code, Code)
6534 inline void ReplaceCode(Code* code); 6539 inline void ReplaceCode(Code* code);
6535 6540
6536 // [optimized_code_map]: Map from native context to optimized code 6541 // [optimized_code_map]: Map from native context to optimized code
6537 // and a shared literals array or Smi(0) if none. 6542 // and a shared literals array or Smi(0) if none.
6538 DECL_ACCESSORS(optimized_code_map, Object) 6543 DECL_ACCESSORS(optimized_code_map, Object)
6539 6544
6540 // Returns index i of the entry with the specified context. At position 6545 // Returns index i of the entry with the specified context and OSR entry.
6541 // i - 1 is the context, position i the code, and i + 1 the literals array. 6546 // At position i - 1 is the context, position i the code, and i + 1 the
6542 // Returns -1 when no matching entry is found. 6547 // literals array. Returns -1 when no matching entry is found.
6543 int SearchOptimizedCodeMap(Context* native_context); 6548 int SearchOptimizedCodeMap(Context* native_context, BailoutId osr_ast_id);
6544 6549
6545 // Installs optimized code from the code map on the given closure. The 6550 // Installs optimized code from the code map on the given closure. The
6546 // index has to be consistent with a search result as defined above. 6551 // index has to be consistent with a search result as defined above.
6547 FixedArray* GetLiteralsFromOptimizedCodeMap(int index); 6552 FixedArray* GetLiteralsFromOptimizedCodeMap(int index);
6548 6553
6549 Code* GetCodeFromOptimizedCodeMap(int index); 6554 Code* GetCodeFromOptimizedCodeMap(int index);
6550 6555
6551 // Clear optimized code map. 6556 // Clear optimized code map.
6552 void ClearOptimizedCodeMap(); 6557 void ClearOptimizedCodeMap();
6553 6558
6554 // Removed a specific optimized code object from the optimized code map. 6559 // Removed a specific optimized code object from the optimized code map.
6555 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); 6560 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason);
6556 6561
6557 // Trims the optimized code map after entries have been removed. 6562 // Trims the optimized code map after entries have been removed.
6558 void TrimOptimizedCodeMap(int shrink_by); 6563 void TrimOptimizedCodeMap(int shrink_by);
6559 6564
6560 // Add a new entry to the optimized code map. 6565 // Add a new entry to the optimized code map.
6561 MUST_USE_RESULT MaybeObject* AddToOptimizedCodeMap(Context* native_context, 6566 MUST_USE_RESULT MaybeObject* AddToOptimizedCodeMap(Context* native_context,
6562 Code* code, 6567 Code* code,
6563 FixedArray* literals); 6568 FixedArray* literals,
6569 BailoutId osr_ast_id);
6564 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 6570 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
6565 Handle<Context> native_context, 6571 Handle<Context> native_context,
6566 Handle<Code> code, 6572 Handle<Code> code,
6567 Handle<FixedArray> literals); 6573 Handle<FixedArray> literals,
6574 BailoutId osr_ast_id);
6568 6575
6569 // Layout description of the optimized code map. 6576 // Layout description of the optimized code map.
6570 static const int kNextMapIndex = 0; 6577 static const int kNextMapIndex = 0;
6571 static const int kEntriesStart = 1; 6578 static const int kEntriesStart = 1;
6572 static const int kEntryLength = 3; 6579 static const int kContextOffset = 0;
6573 static const int kFirstContextSlot = FixedArray::kHeaderSize + kPointerSize; 6580 static const int kCachedCodeOffset = 1;
6574 static const int kFirstCodeSlot = FixedArray::kHeaderSize + 2 * kPointerSize; 6581 static const int kLiteralsOffset = 2;
6582 static const int kOsrAstIdOffset = 3;
6583 static const int kEntryLength = 4;
6584 static const int kFirstContextSlot = FixedArray::kHeaderSize +
6585 (kEntriesStart + kContextOffset) * kPointerSize;
6586 static const int kFirstCodeSlot = FixedArray::kHeaderSize +
6587 (kEntriesStart + kCachedCodeOffset) * kPointerSize;
6588 static const int kFirstOsrAstIdSlot = FixedArray::kHeaderSize +
6589 (kEntriesStart + kOsrAstIdOffset) * kPointerSize;
6575 static const int kSecondEntryIndex = kEntryLength + kEntriesStart; 6590 static const int kSecondEntryIndex = kEntryLength + kEntriesStart;
6576 static const int kInitialLength = kEntriesStart + kEntryLength; 6591 static const int kInitialLength = kEntriesStart + kEntryLength;
6577 6592
6578 // [scope_info]: Scope info. 6593 // [scope_info]: Scope info.
6579 DECL_ACCESSORS(scope_info, ScopeInfo) 6594 DECL_ACCESSORS(scope_info, ScopeInfo)
6580 6595
6581 // [construct stub]: Code stub for constructing instances of this function. 6596 // [construct stub]: Code stub for constructing instances of this function.
6582 DECL_ACCESSORS(construct_stub, Code) 6597 DECL_ACCESSORS(construct_stub, Code)
6583 6598
6584 // Returns if this function has been compiled to native code yet. 6599 // Returns if this function has been compiled to native code yet.
(...skipping 4021 matching lines...) Expand 10 before | Expand all | Expand 10 after
10606 } else { 10621 } else {
10607 value &= ~(1 << bit_position); 10622 value &= ~(1 << bit_position);
10608 } 10623 }
10609 return value; 10624 return value;
10610 } 10625 }
10611 }; 10626 };
10612 10627
10613 } } // namespace v8::internal 10628 } } // namespace v8::internal
10614 10629
10615 #endif // V8_OBJECTS_H_ 10630 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698