Commit 52407c55 authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[ext-code-space] Avoid Code <-> CodeT conversions in runtime, pt.3

This CL
* migrates FeedbackVector::optimized_code to CodeT,
* migrates OSROptimizedCodeCache to CodeT.

Bug: v8:11880
Change-Id: I2082412fb9fdf90e7ed90f4454ecf55f4f3d53d8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3330468Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78367}
parent 907a03d3
...@@ -838,7 +838,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeCache( ...@@ -838,7 +838,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeCache(
RCS_SCOPE(isolate, RuntimeCallCounterId::kCompileGetFromOptimizedCodeMap); RCS_SCOPE(isolate, RuntimeCallCounterId::kCompileGetFromOptimizedCodeMap);
Handle<SharedFunctionInfo> shared(function->shared(), isolate); Handle<SharedFunctionInfo> shared(function->shared(), isolate);
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
Code code; CodeT code;
if (osr_offset.IsNone() && function->has_feedback_vector()) { if (osr_offset.IsNone() && function->has_feedback_vector()) {
FeedbackVector feedback_vector = function->feedback_vector(); FeedbackVector feedback_vector = function->feedback_vector();
feedback_vector.EvictOptimizedCodeMarkedForDeoptimization( feedback_vector.EvictOptimizedCodeMarkedForDeoptimization(
...@@ -858,7 +858,8 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeCache( ...@@ -858,7 +858,8 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeCache(
DCHECK(function->shared().is_compiled()); DCHECK(function->shared().is_compiled());
DCHECK(CodeKindIsStoredInOptimizedCodeCache(code.kind())); DCHECK(CodeKindIsStoredInOptimizedCodeCache(code.kind()));
DCHECK_IMPLIES(!osr_offset.IsNone(), CodeKindCanOSR(code.kind())); DCHECK_IMPLIES(!osr_offset.IsNone(), CodeKindCanOSR(code.kind()));
return Handle<Code>(code, isolate); // TODO(v8:11880): avoid roundtrips between cdc and code.
return Handle<Code>(FromCodeT(code), isolate);
} }
return MaybeHandle<Code>(); return MaybeHandle<Code>();
} }
...@@ -885,14 +886,15 @@ void InsertCodeIntoOptimizedCodeCache( ...@@ -885,14 +886,15 @@ void InsertCodeIntoOptimizedCodeCache(
} }
// Cache optimized code. // Cache optimized code.
Handle<Code> code = compilation_info->code();
Handle<JSFunction> function = compilation_info->closure(); Handle<JSFunction> function = compilation_info->closure();
Handle<SharedFunctionInfo> shared(function->shared(), function->GetIsolate()); Isolate* isolate = function->GetIsolate();
Handle<CodeT> code = ToCodeT(compilation_info->code(), isolate);
Handle<SharedFunctionInfo> shared(function->shared(), isolate);
Handle<NativeContext> native_context(function->context().native_context(), Handle<NativeContext> native_context(function->context().native_context(),
function->GetIsolate()); isolate);
if (compilation_info->osr_offset().IsNone()) { if (compilation_info->osr_offset().IsNone()) {
Handle<FeedbackVector> vector = Handle<FeedbackVector> vector =
handle(function->feedback_vector(), function->GetIsolate()); handle(function->feedback_vector(), isolate);
FeedbackVector::SetOptimizedCode(vector, code, FeedbackVector::SetOptimizedCode(vector, code,
function->raw_feedback_cell()); function->raw_feedback_cell());
} else { } else {
...@@ -1020,8 +1022,7 @@ Handle<Code> ContinuationForConcurrentOptimization( ...@@ -1020,8 +1022,7 @@ Handle<Code> ContinuationForConcurrentOptimization(
// into the feedback vector. // into the feedback vector.
STATIC_ASSERT( STATIC_ASSERT(
FeedbackVector::kFeedbackVectorMaybeOptimizedCodeIsStoreRelease); FeedbackVector::kFeedbackVectorMaybeOptimizedCodeIsStoreRelease);
// TODO(v8:11880): avoid roundtrips between cdc and code. function->set_code(function->feedback_vector().optimized_code());
function->set_code(ToCodeT(function->feedback_vector().optimized_code()));
} }
// TODO(v8:11880): avoid roundtrips between cdc and code. // TODO(v8:11880): avoid roundtrips between cdc and code.
return handle(FromCodeT(function->code()), isolate); return handle(FromCodeT(function->code()), isolate);
...@@ -3306,19 +3307,17 @@ void Compiler::PostInstantiation(Handle<JSFunction> function) { ...@@ -3306,19 +3307,17 @@ void Compiler::PostInstantiation(Handle<JSFunction> function) {
function->feedback_vector().EvictOptimizedCodeMarkedForDeoptimization( function->feedback_vector().EvictOptimizedCodeMarkedForDeoptimization(
function->raw_feedback_cell(), *shared, function->raw_feedback_cell(), *shared,
"new function from shared function info"); "new function from shared function info");
// TODO(v8:11880): avoid roundtrips between cdc and code. CodeT code = function->feedback_vector().optimized_code();
Code code = function->feedback_vector().optimized_code();
if (!code.is_null()) { if (!code.is_null()) {
CodeT codet = ToCodeT(code);
// Caching of optimized code enabled and optimized code found. // Caching of optimized code enabled and optimized code found.
DCHECK(!codet.marked_for_deoptimization()); DCHECK(!code.marked_for_deoptimization());
DCHECK(function->shared().is_compiled()); DCHECK(function->shared().is_compiled());
// We don't need a release store because the optimized code was // We don't need a release store because the optimized code was
// stored with release semantics into the vector // stored with release semantics into the vector
STATIC_ASSERT( STATIC_ASSERT(
FeedbackVector::kFeedbackVectorMaybeOptimizedCodeIsStoreRelease); FeedbackVector::kFeedbackVectorMaybeOptimizedCodeIsStoreRelease);
function->set_code(codet); function->set_code(code);
} }
} }
......
...@@ -8060,7 +8060,7 @@ Handle<CodeT> CompileCWasmEntry(Isolate* isolate, const wasm::FunctionSig* sig, ...@@ -8060,7 +8060,7 @@ Handle<CodeT> CompileCWasmEntry(Isolate* isolate, const wasm::FunctionSig* sig,
CHECK_NE(job->FinalizeJob(isolate), CompilationJob::FAILED); CHECK_NE(job->FinalizeJob(isolate), CompilationJob::FAILED);
#ifdef V8_EXTERNAL_CODE_SPACE #ifdef V8_EXTERNAL_CODE_SPACE
return handle(ToCodeT(*job->compilation_info()->code()), isolate); return ToCodeT(job->compilation_info()->code(), isolate);
#else #else
return job->compilation_info()->code(); return job->compilation_info()->code();
#endif #endif
......
...@@ -266,6 +266,14 @@ inline CodeT ToCodeT(Code code) { ...@@ -266,6 +266,14 @@ inline CodeT ToCodeT(Code code) {
#endif #endif
} }
inline Handle<CodeT> ToCodeT(Handle<Code> code, Isolate* isolate) {
#ifdef V8_EXTERNAL_CODE_SPACE
return handle(code->code_data_container(kAcquireLoad), isolate);
#else
return code;
#endif
}
inline Code FromCodeT(CodeT code) { inline Code FromCodeT(CodeT code) {
#ifdef V8_EXTERNAL_CODE_SPACE #ifdef V8_EXTERNAL_CODE_SPACE
return code.code(); return code.code();
...@@ -1028,6 +1036,10 @@ bool CodeDataContainer::is_builtin() const { ...@@ -1028,6 +1036,10 @@ bool CodeDataContainer::is_builtin() const {
return builtin_id() != Builtin::kNoBuiltinId; return builtin_id() != Builtin::kNoBuiltinId;
} }
bool CodeDataContainer::is_optimized_code() const {
return CodeKindIsOptimizedJSFunction(kind());
}
inline bool CodeDataContainer::is_interpreter_trampoline_builtin() const { inline bool CodeDataContainer::is_interpreter_trampoline_builtin() const {
return IsInterpreterTrampolineBuiltin(builtin_id()); return IsInterpreterTrampolineBuiltin(builtin_id());
} }
......
...@@ -753,6 +753,7 @@ class Code::OptimizedCodeIterator { ...@@ -753,6 +753,7 @@ class Code::OptimizedCodeIterator {
// Helper functions for converting Code objects to CodeDataContainer and back // Helper functions for converting Code objects to CodeDataContainer and back
// when V8_EXTERNAL_CODE_SPACE is enabled. // when V8_EXTERNAL_CODE_SPACE is enabled.
inline CodeT ToCodeT(Code code); inline CodeT ToCodeT(Code code);
inline Handle<CodeT> ToCodeT(Handle<Code> code, Isolate* isolate);
inline Code FromCodeT(CodeT code); inline Code FromCodeT(CodeT code);
inline Code FromCodeT(CodeT code, RelaxedLoadTag); inline Code FromCodeT(CodeT code, RelaxedLoadTag);
inline Code FromCodeT(CodeT code, AcquireLoadTag); inline Code FromCodeT(CodeT code, AcquireLoadTag);
......
...@@ -124,13 +124,13 @@ void FeedbackVector::clear_invocation_count(RelaxedStoreTag tag) { ...@@ -124,13 +124,13 @@ void FeedbackVector::clear_invocation_count(RelaxedStoreTag tag) {
set_invocation_count(0, tag); set_invocation_count(0, tag);
} }
Code FeedbackVector::optimized_code() const { CodeT FeedbackVector::optimized_code() const {
MaybeObject slot = maybe_optimized_code(kAcquireLoad); MaybeObject slot = maybe_optimized_code(kAcquireLoad);
DCHECK(slot->IsWeakOrCleared()); DCHECK(slot->IsWeakOrCleared());
HeapObject heap_object; HeapObject heap_object;
Code code; CodeT code;
if (slot->GetHeapObject(&heap_object)) { if (slot->GetHeapObject(&heap_object)) {
code = FromCodeT(CodeT::cast(heap_object)); code = CodeT::cast(heap_object);
} }
// It is possible that the maybe_optimized_code slot is cleared but the // It is possible that the maybe_optimized_code slot is cleared but the
// optimization tier hasn't been updated yet. We update the tier when we // optimization tier hasn't been updated yet. We update the tier when we
......
...@@ -390,7 +390,7 @@ void FeedbackVector::SaturatingIncrementProfilerTicks() { ...@@ -390,7 +390,7 @@ void FeedbackVector::SaturatingIncrementProfilerTicks() {
// static // static
void FeedbackVector::SetOptimizedCode(Handle<FeedbackVector> vector, void FeedbackVector::SetOptimizedCode(Handle<FeedbackVector> vector,
Handle<Code> code, Handle<CodeT> code,
FeedbackCell feedback_cell) { FeedbackCell feedback_cell) {
DCHECK(CodeKindIsOptimizedJSFunction(code->kind())); DCHECK(CodeKindIsOptimizedJSFunction(code->kind()));
// We should set optimized code only when there is no valid optimized code or // We should set optimized code only when there is no valid optimized code or
...@@ -405,7 +405,7 @@ void FeedbackVector::SetOptimizedCode(Handle<FeedbackVector> vector, ...@@ -405,7 +405,7 @@ void FeedbackVector::SetOptimizedCode(Handle<FeedbackVector> vector,
// re-mark the function for non-concurrent optimization after an OSR. We // re-mark the function for non-concurrent optimization after an OSR. We
// should avoid these cases and also check that marker isn't // should avoid these cases and also check that marker isn't
// kCompileOptimized or kCompileOptimizedConcurrent. // kCompileOptimized or kCompileOptimizedConcurrent.
vector->set_maybe_optimized_code(HeapObjectReference::Weak(ToCodeT(*code)), vector->set_maybe_optimized_code(HeapObjectReference::Weak(*code),
kReleaseStore); kReleaseStore);
int32_t state = vector->flags(); int32_t state = vector->flags();
state = OptimizationTierBits::update(state, GetTierForCodeKind(code->kind())); state = OptimizationTierBits::update(state, GetTierForCodeKind(code->kind()));
......
...@@ -236,7 +236,7 @@ class FeedbackVector ...@@ -236,7 +236,7 @@ class FeedbackVector
DECL_RELAXED_INT32_ACCESSORS(invocation_count) DECL_RELAXED_INT32_ACCESSORS(invocation_count)
inline void clear_invocation_count(RelaxedStoreTag tag); inline void clear_invocation_count(RelaxedStoreTag tag);
inline Code optimized_code() const; inline CodeT optimized_code() const;
inline bool has_optimized_code() const; inline bool has_optimized_code() const;
inline bool has_optimization_marker() const; inline bool has_optimization_marker() const;
inline OptimizationMarker optimization_marker() const; inline OptimizationMarker optimization_marker() const;
...@@ -245,8 +245,8 @@ class FeedbackVector ...@@ -245,8 +245,8 @@ class FeedbackVector
void EvictOptimizedCodeMarkedForDeoptimization(FeedbackCell feedback_cell, void EvictOptimizedCodeMarkedForDeoptimization(FeedbackCell feedback_cell,
SharedFunctionInfo shared, SharedFunctionInfo shared,
const char* reason); const char* reason);
static void SetOptimizedCode(Handle<FeedbackVector> vector, Handle<Code> code, static void SetOptimizedCode(Handle<FeedbackVector> vector,
FeedbackCell feedback_cell); Handle<CodeT> code, FeedbackCell feedback_cell);
void SetOptimizationMarker(OptimizationMarker marker); void SetOptimizationMarker(OptimizationMarker marker);
void ClearOptimizationTier(FeedbackCell feedback_cell); void ClearOptimizationTier(FeedbackCell feedback_cell);
void InitializeOptimizationState(); void InitializeOptimizationState();
......
...@@ -48,7 +48,7 @@ CodeKinds JSFunction::GetAvailableCodeKinds() const { ...@@ -48,7 +48,7 @@ CodeKinds JSFunction::GetAvailableCodeKinds() const {
// Check the optimized code cache. // Check the optimized code cache.
if (has_feedback_vector() && feedback_vector().has_optimized_code() && if (has_feedback_vector() && feedback_vector().has_optimized_code() &&
!feedback_vector().optimized_code().marked_for_deoptimization()) { !feedback_vector().optimized_code().marked_for_deoptimization()) {
Code code = feedback_vector().optimized_code(); CodeT code = feedback_vector().optimized_code();
DCHECK(CodeKindIsOptimizedJSFunction(code.kind())); DCHECK(CodeKindIsOptimizedJSFunction(code.kind()));
result |= CodeKindToCodeKindFlag(code.kind()); result |= CodeKindToCodeKindFlag(code.kind());
} }
......
...@@ -17,7 +17,7 @@ const int OSROptimizedCodeCache::kMaxLength; ...@@ -17,7 +17,7 @@ const int OSROptimizedCodeCache::kMaxLength;
void OSROptimizedCodeCache::AddOptimizedCode( void OSROptimizedCodeCache::AddOptimizedCode(
Handle<NativeContext> native_context, Handle<SharedFunctionInfo> shared, Handle<NativeContext> native_context, Handle<SharedFunctionInfo> shared,
Handle<Code> code, BytecodeOffset osr_offset) { Handle<CodeT> code, BytecodeOffset osr_offset) {
DCHECK(!osr_offset.IsNone()); DCHECK(!osr_offset.IsNone());
DCHECK(CodeKindIsOptimizedJSFunction(code->kind())); DCHECK(CodeKindIsOptimizedJSFunction(code->kind()));
STATIC_ASSERT(kEntryLength == 3); STATIC_ASSERT(kEntryLength == 3);
...@@ -90,16 +90,16 @@ void OSROptimizedCodeCache::Compact(Handle<NativeContext> native_context) { ...@@ -90,16 +90,16 @@ void OSROptimizedCodeCache::Compact(Handle<NativeContext> native_context) {
native_context->set_osr_code_cache(*new_osr_cache); native_context->set_osr_code_cache(*new_osr_cache);
} }
Code OSROptimizedCodeCache::GetOptimizedCode(Handle<SharedFunctionInfo> shared, CodeT OSROptimizedCodeCache::GetOptimizedCode(Handle<SharedFunctionInfo> shared,
BytecodeOffset osr_offset, BytecodeOffset osr_offset,
Isolate* isolate) { Isolate* isolate) {
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
int index = FindEntry(shared, osr_offset); int index = FindEntry(shared, osr_offset);
if (index == -1) return Code(); if (index == -1) return CodeT();
Code code = GetCodeFromEntry(index); CodeT code = GetCodeFromEntry(index);
if (code.is_null()) { if (code.is_null()) {
ClearEntry(index, isolate); ClearEntry(index, isolate);
return code; return CodeT();
} }
DCHECK(code.is_optimized_code() && !code.marked_for_deoptimization()); DCHECK(code.is_optimized_code() && !code.marked_for_deoptimization());
return code; return code;
...@@ -114,8 +114,7 @@ void OSROptimizedCodeCache::EvictMarkedCode(Isolate* isolate) { ...@@ -114,8 +114,7 @@ void OSROptimizedCodeCache::EvictMarkedCode(Isolate* isolate) {
HeapObject heap_object; HeapObject heap_object;
if (!code_entry->GetHeapObject(&heap_object)) continue; if (!code_entry->GetHeapObject(&heap_object)) continue;
// TODO(v8:11880): avoid roundtrips between cdc and code. CodeT code = CodeT::cast(heap_object);
Code code = FromCodeT(CodeT::cast(heap_object));
DCHECK(code.is_optimized_code()); DCHECK(code.is_optimized_code());
if (!code.marked_for_deoptimization()) continue; if (!code.marked_for_deoptimization()) continue;
...@@ -140,15 +139,14 @@ int OSROptimizedCodeCache::GrowOSRCache( ...@@ -140,15 +139,14 @@ int OSROptimizedCodeCache::GrowOSRCache(
return old_length; return old_length;
} }
Code OSROptimizedCodeCache::GetCodeFromEntry(int index) { CodeT OSROptimizedCodeCache::GetCodeFromEntry(int index) {
DCHECK_LE(index + OSRCodeCacheConstants::kEntryLength, length()); DCHECK_LE(index + OSRCodeCacheConstants::kEntryLength, length());
DCHECK_EQ(index % kEntryLength, 0); DCHECK_EQ(index % kEntryLength, 0);
HeapObject code_entry; HeapObject code_entry;
Get(index + OSRCodeCacheConstants::kCachedCodeOffset) Get(index + OSRCodeCacheConstants::kCachedCodeOffset)
->GetHeapObject(&code_entry); ->GetHeapObject(&code_entry);
if (code_entry.is_null()) return Code(); if (code_entry.is_null()) return CodeT();
// TODO(v8:11880): avoid roundtrips between cdc and code. return CodeT::cast(code_entry);
return FromCodeT(CodeT::cast(code_entry));
} }
SharedFunctionInfo OSROptimizedCodeCache::GetSFIFromEntry(int index) { SharedFunctionInfo OSROptimizedCodeCache::GetSFIFromEntry(int index) {
...@@ -191,13 +189,11 @@ void OSROptimizedCodeCache::ClearEntry(int index, Isolate* isolate) { ...@@ -191,13 +189,11 @@ void OSROptimizedCodeCache::ClearEntry(int index, Isolate* isolate) {
void OSROptimizedCodeCache::InitializeEntry(int entry, void OSROptimizedCodeCache::InitializeEntry(int entry,
SharedFunctionInfo shared, SharedFunctionInfo shared,
Code code, CodeT code,
BytecodeOffset osr_offset) { BytecodeOffset osr_offset) {
Set(entry + OSRCodeCacheConstants::kSharedOffset, Set(entry + OSRCodeCacheConstants::kSharedOffset,
HeapObjectReference::Weak(shared)); HeapObjectReference::Weak(shared));
// TODO(v8:11880): avoid roundtrips between cdc and code. HeapObjectReference weak_code_entry = HeapObjectReference::Weak(code);
HeapObjectReference weak_code_entry =
HeapObjectReference::Weak(ToCodeT(code));
Set(entry + OSRCodeCacheConstants::kCachedCodeOffset, weak_code_entry); Set(entry + OSRCodeCacheConstants::kCachedCodeOffset, weak_code_entry);
Set(entry + OSRCodeCacheConstants::kOsrIdOffset, Set(entry + OSRCodeCacheConstants::kOsrIdOffset,
MaybeObject::FromSmi(Smi::FromInt(osr_offset.ToInt()))); MaybeObject::FromSmi(Smi::FromInt(osr_offset.ToInt())));
......
...@@ -32,7 +32,7 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray { ...@@ -32,7 +32,7 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray {
// kOSRCodeCacheInitialLength entries. // kOSRCodeCacheInitialLength entries.
static void AddOptimizedCode(Handle<NativeContext> context, static void AddOptimizedCode(Handle<NativeContext> context,
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared,
Handle<Code> code, BytecodeOffset osr_offset); Handle<CodeT> code, BytecodeOffset osr_offset);
// Reduces the size of the OSR code cache if the number of valid entries are // Reduces the size of the OSR code cache if the number of valid entries are
// less than the current capacity of the cache. // less than the current capacity of the cache.
static void Compact(Handle<NativeContext> context); static void Compact(Handle<NativeContext> context);
...@@ -42,8 +42,8 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray { ...@@ -42,8 +42,8 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray {
// Returns the code corresponding to the shared function |shared| and // Returns the code corresponding to the shared function |shared| and
// BytecodeOffset |offset| if an entry exists in the cache. Returns an empty // BytecodeOffset |offset| if an entry exists in the cache. Returns an empty
// object otherwise. // object otherwise.
Code GetOptimizedCode(Handle<SharedFunctionInfo> shared, CodeT GetOptimizedCode(Handle<SharedFunctionInfo> shared,
BytecodeOffset osr_offset, Isolate* isolate); BytecodeOffset osr_offset, Isolate* isolate);
// Remove all code objects marked for deoptimization from OSR code cache. // Remove all code objects marked for deoptimization from OSR code cache.
void EvictMarkedCode(Isolate* isolate); void EvictMarkedCode(Isolate* isolate);
...@@ -56,14 +56,14 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray { ...@@ -56,14 +56,14 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray {
Handle<OSROptimizedCodeCache>* osr_cache); Handle<OSROptimizedCodeCache>* osr_cache);
// Helper functions to get individual items from an entry in the cache. // Helper functions to get individual items from an entry in the cache.
Code GetCodeFromEntry(int index); CodeT GetCodeFromEntry(int index);
SharedFunctionInfo GetSFIFromEntry(int index); SharedFunctionInfo GetSFIFromEntry(int index);
BytecodeOffset GetBytecodeOffsetFromEntry(int index); BytecodeOffset GetBytecodeOffsetFromEntry(int index);
inline int FindEntry(Handle<SharedFunctionInfo> shared, inline int FindEntry(Handle<SharedFunctionInfo> shared,
BytecodeOffset osr_offset); BytecodeOffset osr_offset);
inline void ClearEntry(int src, Isolate* isolate); inline void ClearEntry(int src, Isolate* isolate);
inline void InitializeEntry(int entry, SharedFunctionInfo shared, Code code, inline void InitializeEntry(int entry, SharedFunctionInfo shared, CodeT code,
BytecodeOffset osr_offset); BytecodeOffset osr_offset);
inline void MoveEntry(int src, int dst, Isolate* isolate); inline void MoveEntry(int src, int dst, Isolate* isolate);
......
...@@ -50,7 +50,7 @@ TEST_F(TestWithNativeContext, AddCodeToEmptyCache) { ...@@ -50,7 +50,7 @@ TEST_F(TestWithNativeContext, AddCodeToEmptyCache) {
Isolate* isolate = function->GetIsolate(); Isolate* isolate = function->GetIsolate();
Handle<NativeContext> native_context(function->native_context(), isolate); Handle<NativeContext> native_context(function->native_context(), isolate);
Handle<SharedFunctionInfo> shared(function->shared(), isolate); Handle<SharedFunctionInfo> shared(function->shared(), isolate);
Handle<Code> code(FromCodeT(function->code()), isolate); Handle<CodeT> code(function->code(), isolate);
BytecodeOffset bailout_id(1); BytecodeOffset bailout_id(1);
OSROptimizedCodeCache::AddOptimizedCode(native_context, shared, code, OSROptimizedCodeCache::AddOptimizedCode(native_context, shared, code,
bailout_id); bailout_id);
...@@ -66,7 +66,7 @@ TEST_F(TestWithNativeContext, AddCodeToEmptyCache) { ...@@ -66,7 +66,7 @@ TEST_F(TestWithNativeContext, AddCodeToEmptyCache) {
HeapObject code_entry; HeapObject code_entry;
osr_cache->Get(OSROptimizedCodeCache::kCachedCodeOffset) osr_cache->Get(OSROptimizedCodeCache::kCachedCodeOffset)
->GetHeapObject(&code_entry); ->GetHeapObject(&code_entry);
EXPECT_EQ(code_entry, ToCodeT(*code)); EXPECT_EQ(code_entry, *code);
Smi osr_offset_entry; Smi osr_offset_entry;
osr_cache->Get(OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&osr_offset_entry); osr_cache->Get(OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&osr_offset_entry);
EXPECT_EQ(osr_offset_entry.value(), bailout_id.ToInt()); EXPECT_EQ(osr_offset_entry.value(), bailout_id.ToInt());
...@@ -83,7 +83,7 @@ TEST_F(TestWithNativeContext, GrowCodeCache) { ...@@ -83,7 +83,7 @@ TEST_F(TestWithNativeContext, GrowCodeCache) {
Isolate* isolate = function->GetIsolate(); Isolate* isolate = function->GetIsolate();
Handle<NativeContext> native_context(function->native_context(), isolate); Handle<NativeContext> native_context(function->native_context(), isolate);
Handle<SharedFunctionInfo> shared(function->shared(), isolate); Handle<SharedFunctionInfo> shared(function->shared(), isolate);
Handle<Code> code(FromCodeT(function->code()), isolate); Handle<CodeT> code(function->code(), isolate);
int bailout_id = 0; int bailout_id = 0;
for (bailout_id = 0; bailout_id < kInitialEntries; bailout_id++) { for (bailout_id = 0; bailout_id < kInitialEntries; bailout_id++) {
...@@ -108,7 +108,7 @@ TEST_F(TestWithNativeContext, GrowCodeCache) { ...@@ -108,7 +108,7 @@ TEST_F(TestWithNativeContext, GrowCodeCache) {
HeapObject code_entry; HeapObject code_entry;
osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset) osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset)
->GetHeapObject(&code_entry); ->GetHeapObject(&code_entry);
EXPECT_EQ(code_entry, ToCodeT(*code)); EXPECT_EQ(code_entry, *code);
Smi osr_offset_entry; Smi osr_offset_entry;
osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset) osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset)
->ToSmi(&osr_offset_entry); ->ToSmi(&osr_offset_entry);
...@@ -126,7 +126,7 @@ TEST_F(TestWithNativeContext, FindCachedEntry) { ...@@ -126,7 +126,7 @@ TEST_F(TestWithNativeContext, FindCachedEntry) {
Isolate* isolate = function->GetIsolate(); Isolate* isolate = function->GetIsolate();
Handle<NativeContext> native_context(function->native_context(), isolate); Handle<NativeContext> native_context(function->native_context(), isolate);
Handle<SharedFunctionInfo> shared(function->shared(), isolate); Handle<SharedFunctionInfo> shared(function->shared(), isolate);
Handle<Code> code(FromCodeT(function->code()), isolate); Handle<CodeT> code(function->code(), isolate);
int bailout_id = 0; int bailout_id = 0;
for (bailout_id = 0; bailout_id < kInitialEntries; bailout_id++) { for (bailout_id = 0; bailout_id < kInitialEntries; bailout_id++) {
...@@ -138,7 +138,7 @@ TEST_F(TestWithNativeContext, FindCachedEntry) { ...@@ -138,7 +138,7 @@ TEST_F(TestWithNativeContext, FindCachedEntry) {
GetSource(&source1, 1); GetSource(&source1, 1);
Handle<JSFunction> function1 = RunJS<JSFunction>(source1.begin()); Handle<JSFunction> function1 = RunJS<JSFunction>(source1.begin());
Handle<SharedFunctionInfo> shared1(function1->shared(), isolate); Handle<SharedFunctionInfo> shared1(function1->shared(), isolate);
Handle<Code> code1(FromCodeT(function1->code()), isolate); Handle<CodeT> code1(function1->code(), isolate);
OSROptimizedCodeCache::AddOptimizedCode(native_context, shared1, code1, OSROptimizedCodeCache::AddOptimizedCode(native_context, shared1, code1,
BytecodeOffset(bailout_id)); BytecodeOffset(bailout_id));
...@@ -172,7 +172,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) { ...@@ -172,7 +172,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) {
Isolate* isolate = function->GetIsolate(); Isolate* isolate = function->GetIsolate();
Handle<NativeContext> native_context(function->native_context(), isolate); Handle<NativeContext> native_context(function->native_context(), isolate);
Handle<SharedFunctionInfo> shared(function->shared(), isolate); Handle<SharedFunctionInfo> shared(function->shared(), isolate);
Handle<Code> code(FromCodeT(function->code()), isolate); Handle<CodeT> code(function->code(), isolate);
int bailout_id = 0; int bailout_id = 0;
// Add max_capacity - 1 entries. // Add max_capacity - 1 entries.
...@@ -189,7 +189,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) { ...@@ -189,7 +189,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) {
GetSource(&source1, 1); GetSource(&source1, 1);
Handle<JSFunction> function1 = RunJS<JSFunction>(source1.begin()); Handle<JSFunction> function1 = RunJS<JSFunction>(source1.begin());
Handle<SharedFunctionInfo> shared1(function1->shared(), isolate); Handle<SharedFunctionInfo> shared1(function1->shared(), isolate);
Handle<Code> code1(FromCodeT(function1->code()), isolate); Handle<CodeT> code1(function1->code(), isolate);
OSROptimizedCodeCache::AddOptimizedCode(native_context, shared1, code1, OSROptimizedCodeCache::AddOptimizedCode(native_context, shared1, code1,
BytecodeOffset(bailout_id)); BytecodeOffset(bailout_id));
osr_cache = Handle<OSROptimizedCodeCache>( osr_cache = Handle<OSROptimizedCodeCache>(
...@@ -204,7 +204,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) { ...@@ -204,7 +204,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) {
EXPECT_EQ(object, *shared1); EXPECT_EQ(object, *shared1);
osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset) osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset)
->GetHeapObject(&object); ->GetHeapObject(&object);
EXPECT_EQ(object, ToCodeT(*code1)); EXPECT_EQ(object, *code1);
osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&smi); osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&smi);
EXPECT_EQ(smi.value(), bailout_id); EXPECT_EQ(smi.value(), bailout_id);
...@@ -213,7 +213,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) { ...@@ -213,7 +213,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) {
GetSource(&source2, 2); GetSource(&source2, 2);
Handle<JSFunction> function2 = RunJS<JSFunction>(source2.begin()); Handle<JSFunction> function2 = RunJS<JSFunction>(source2.begin());
Handle<SharedFunctionInfo> shared2(function2->shared(), isolate); Handle<SharedFunctionInfo> shared2(function2->shared(), isolate);
Handle<Code> code2(FromCodeT(function2->code()), isolate); Handle<CodeT> code2(function2->code(), isolate);
bailout_id++; bailout_id++;
OSROptimizedCodeCache::AddOptimizedCode(native_context, shared2, code2, OSROptimizedCodeCache::AddOptimizedCode(native_context, shared2, code2,
BytecodeOffset(bailout_id)); BytecodeOffset(bailout_id));
...@@ -227,7 +227,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) { ...@@ -227,7 +227,7 @@ TEST_F(TestWithNativeContext, MaxCapacityCache) {
EXPECT_EQ(object, *shared2); EXPECT_EQ(object, *shared2);
osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset) osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset)
->GetHeapObject(&object); ->GetHeapObject(&object);
EXPECT_EQ(object, ToCodeT(*code2)); EXPECT_EQ(object, *code2);
osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&smi); osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&smi);
EXPECT_EQ(smi.value(), bailout_id); EXPECT_EQ(smi.value(), bailout_id);
} }
...@@ -243,7 +243,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) { ...@@ -243,7 +243,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) {
Isolate* isolate = function->GetIsolate(); Isolate* isolate = function->GetIsolate();
Handle<NativeContext> native_context(function->native_context(), isolate); Handle<NativeContext> native_context(function->native_context(), isolate);
Handle<SharedFunctionInfo> shared(function->shared(), isolate); Handle<SharedFunctionInfo> shared(function->shared(), isolate);
Handle<Code> code(FromCodeT(function->code()), isolate); Handle<CodeT> code(function->code(), isolate);
int num_entries = kInitialEntries * 2; int num_entries = kInitialEntries * 2;
int expected_length = kInitialLength * 2; int expected_length = kInitialLength * 2;
...@@ -267,7 +267,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) { ...@@ -267,7 +267,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) {
GetSource(&source1, 1); GetSource(&source1, 1);
Handle<JSFunction> function1 = RunJS<JSFunction>(source1.begin()); Handle<JSFunction> function1 = RunJS<JSFunction>(source1.begin());
Handle<SharedFunctionInfo> shared1(function1->shared(), isolate); Handle<SharedFunctionInfo> shared1(function1->shared(), isolate);
Handle<Code> code1(FromCodeT(function1->code()), isolate); Handle<CodeT> code1(function1->code(), isolate);
OSROptimizedCodeCache::AddOptimizedCode(native_context, shared1, code1, OSROptimizedCodeCache::AddOptimizedCode(native_context, shared1, code1,
BytecodeOffset(bailout_id)); BytecodeOffset(bailout_id));
osr_cache = Handle<OSROptimizedCodeCache>( osr_cache = Handle<OSROptimizedCodeCache>(
...@@ -282,7 +282,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) { ...@@ -282,7 +282,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) {
EXPECT_EQ(object, *shared1); EXPECT_EQ(object, *shared1);
osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset) osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset)
->GetHeapObject(&object); ->GetHeapObject(&object);
EXPECT_EQ(object, ToCodeT(*code1)); EXPECT_EQ(object, *code1);
osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&smi); osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&smi);
EXPECT_EQ(smi.value(), bailout_id); EXPECT_EQ(smi.value(), bailout_id);
...@@ -290,7 +290,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) { ...@@ -290,7 +290,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) {
GetSource(&source2, 2); GetSource(&source2, 2);
Handle<JSFunction> function2 = RunJS<JSFunction>(source2.begin()); Handle<JSFunction> function2 = RunJS<JSFunction>(source2.begin());
Handle<SharedFunctionInfo> shared2(function2->shared(), isolate); Handle<SharedFunctionInfo> shared2(function2->shared(), isolate);
Handle<Code> code2(FromCodeT(function2->code()), isolate); Handle<CodeT> code2(function2->code(), isolate);
bailout_id++; bailout_id++;
OSROptimizedCodeCache::AddOptimizedCode(native_context, shared2, code2, OSROptimizedCodeCache::AddOptimizedCode(native_context, shared2, code2,
BytecodeOffset(bailout_id)); BytecodeOffset(bailout_id));
...@@ -304,7 +304,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) { ...@@ -304,7 +304,7 @@ TEST_F(TestWithNativeContext, ReuseClearedEntry) {
EXPECT_EQ(object, *shared2); EXPECT_EQ(object, *shared2);
osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset) osr_cache->Get(index + OSROptimizedCodeCache::kCachedCodeOffset)
->GetHeapObject(&object); ->GetHeapObject(&object);
EXPECT_EQ(object, ToCodeT(*code2)); EXPECT_EQ(object, *code2);
osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&smi); osr_cache->Get(index + OSROptimizedCodeCache::kOsrIdOffset)->ToSmi(&smi);
EXPECT_EQ(smi.value(), bailout_id); EXPECT_EQ(smi.value(), bailout_id);
} }
...@@ -320,13 +320,13 @@ TEST_F(TestWithNativeContext, EvictDeoptedEntriesNoCompact) { ...@@ -320,13 +320,13 @@ TEST_F(TestWithNativeContext, EvictDeoptedEntriesNoCompact) {
Isolate* isolate = function->GetIsolate(); Isolate* isolate = function->GetIsolate();
Handle<NativeContext> native_context(function->native_context(), isolate); Handle<NativeContext> native_context(function->native_context(), isolate);
Handle<SharedFunctionInfo> shared(function->shared(), isolate); Handle<SharedFunctionInfo> shared(function->shared(), isolate);
Handle<Code> code(FromCodeT(function->code()), isolate); Handle<CodeT> code(function->code(), isolate);
base::ScopedVector<char> source1(1024); base::ScopedVector<char> source1(1024);
GetSource(&source1, 1); GetSource(&source1, 1);
Handle<JSFunction> deopt_function = RunJS<JSFunction>(source1.begin()); Handle<JSFunction> deopt_function = RunJS<JSFunction>(source1.begin());
Handle<SharedFunctionInfo> deopt_shared(deopt_function->shared(), isolate); Handle<SharedFunctionInfo> deopt_shared(deopt_function->shared(), isolate);
Handle<Code> deopt_code(FromCodeT(deopt_function->code()), isolate); Handle<CodeT> deopt_code(deopt_function->code(), isolate);
int num_entries = kInitialEntries * 2; int num_entries = kInitialEntries * 2;
int expected_length = kInitialLength * 2; int expected_length = kInitialLength * 2;
...@@ -379,13 +379,13 @@ TEST_F(TestWithNativeContext, EvictDeoptedEntriesCompact) { ...@@ -379,13 +379,13 @@ TEST_F(TestWithNativeContext, EvictDeoptedEntriesCompact) {
Isolate* isolate = function->GetIsolate(); Isolate* isolate = function->GetIsolate();
Handle<NativeContext> native_context(function->native_context(), isolate); Handle<NativeContext> native_context(function->native_context(), isolate);
Handle<SharedFunctionInfo> shared(function->shared(), isolate); Handle<SharedFunctionInfo> shared(function->shared(), isolate);
Handle<Code> code(FromCodeT(function->code()), isolate); Handle<CodeT> code(function->code(), isolate);
base::ScopedVector<char> source1(1024); base::ScopedVector<char> source1(1024);
GetSource(&source1, 1); GetSource(&source1, 1);
Handle<JSFunction> deopt_function = RunJS<JSFunction>(source1.begin()); Handle<JSFunction> deopt_function = RunJS<JSFunction>(source1.begin());
Handle<SharedFunctionInfo> deopt_shared(deopt_function->shared(), isolate); Handle<SharedFunctionInfo> deopt_shared(deopt_function->shared(), isolate);
Handle<Code> deopt_code(FromCodeT(deopt_function->code()), isolate); Handle<CodeT> deopt_code(deopt_function->code(), isolate);
int num_entries = kInitialEntries + 1; int num_entries = kInitialEntries + 1;
int expected_length = kInitialLength * 2; int expected_length = kInitialLength * 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment