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

Unified Diff: src/objects.cc

Issue 1208013002: [turbofan] Implement sharing of context-independent code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_opt-code-map-3
Patch Set: Disable test for GC stress. Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 0f90a338d4fa26bf2a1cc5f3f1a55aca8541c44a..715972e10666e733a376e27e771c1ca5d214869c 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9568,6 +9568,17 @@ Handle<JSFunction> JSFunction::CloneClosure(Handle<JSFunction> function) {
}
+void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(
+ Handle<SharedFunctionInfo> shared, Handle<Code> code) {
+ Isolate* isolate = shared->GetIsolate();
+ DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION);
+ Handle<Object> value(shared->optimized_code_map(), isolate);
+ if (value->IsSmi()) return; // Empty code maps are unsupported.
+ Handle<FixedArray> code_map = Handle<FixedArray>::cast(value);
+ code_map->set(kSharedCodeIndex, *code);
+}
+
+
void SharedFunctionInfo::AddToOptimizedCodeMap(
Handle<SharedFunctionInfo> shared,
Handle<Context> native_context,
@@ -9584,7 +9595,6 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
if (value->IsSmi()) {
// No optimized code map.
DCHECK_EQ(0, Smi::cast(*value)->value());
- // Create 3 entries per context {context, code, literals}.
new_code_map = isolate->factory()->NewFixedArray(kInitialLength);
old_length = kEntriesStart;
} else {
@@ -9672,6 +9682,15 @@ void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code,
dst += kEntryLength;
}
}
+ if (code_map->get(kSharedCodeIndex) == optimized_code) {
+ // Evict context-independent code as well.
+ code_map->set_undefined(kSharedCodeIndex);
+ if (FLAG_trace_opt) {
+ PrintF("[evicting entry from optimizing code map (%s) for ", reason);
+ ShortPrint();
+ PrintF(" (context-independent code)]\n");
+ }
+ }
if (dst != length) {
// Always trim even when array is cleared because of heap verifier.
GetHeap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(code_map,
@@ -10659,6 +10678,10 @@ CodeAndLiterals SharedFunctionInfo::SearchOptimizedCodeMap(
FixedArray::cast(optimized_code_map->get(i + kLiteralsOffset))};
}
}
+ Object* shared_code = optimized_code_map->get(kSharedCodeIndex);
+ if (shared_code->IsCode() && osr_ast_id.IsNone()) {
+ return {Code::cast(shared_code), nullptr};
+ }
if (FLAG_trace_opt) {
PrintF("[didn't find optimized code in optimized code map for ");
ShortPrint();
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698