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

Unified Diff: src/objects.cc

Issue 1516833002: Tighten the interface to the optimized code map (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nit. Created 5 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 side-by-side diff with in-line comments
Download patch
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('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 bef6dba7932e0297f3471f22b7829395c6379a24..8b6afc36bb09463c51921ad344ac81ffc4df1000 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -11989,7 +11989,7 @@ void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(
}
-void SharedFunctionInfo::AddToOptimizedCodeMap(
+void SharedFunctionInfo::AddToOptimizedCodeMapInternal(
Handle<SharedFunctionInfo> shared, Handle<Context> native_context,
Handle<HeapObject> code, Handle<LiteralsArray> literals,
BailoutId osr_ast_id) {
@@ -12001,6 +12001,7 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
Code::cast(*code)->kind() == Code::OPTIMIZED_FUNCTION);
DCHECK(native_context->IsNativeContext());
STATIC_ASSERT(kEntryLength == 4);
+ Handle<FixedArray> old_code_map(shared->optimized_code_map(), isolate);
Handle<FixedArray> new_code_map;
int entry;
@@ -12010,19 +12011,21 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
SKIP_WRITE_BARRIER);
entry = kEntriesStart;
} else {
- Handle<FixedArray> old_code_map(shared->optimized_code_map(), isolate);
entry = shared->SearchOptimizedCodeMapEntry(*native_context, osr_ast_id);
if (entry > kSharedCodeIndex) {
- // Found an existing context-specific entry, it must not contain any code.
- DCHECK(WeakCell::cast(old_code_map->get(entry + kCachedCodeOffset))
+ // Found an existing context-specific entry. If the user provided valid
+ // code, it must not contain any code.
+ DCHECK(code->IsUndefined() ||
+ WeakCell::cast(old_code_map->get(entry + kCachedCodeOffset))
->cleared());
+
// Just set the code and literals to the entry.
- Handle<WeakCell> code_cell = code->IsUndefined()
- ? isolate->factory()->empty_weak_cell()
- : isolate->factory()->NewWeakCell(code);
+ if (!code->IsUndefined()) {
+ Handle<WeakCell> code_cell = isolate->factory()->NewWeakCell(code);
+ old_code_map->set(entry + kCachedCodeOffset, *code_cell);
+ }
Handle<WeakCell> literals_cell =
isolate->factory()->NewWeakCell(literals);
- old_code_map->set(entry + kCachedCodeOffset, *code_cell);
old_code_map->set(entry + kLiteralsOffset, *literals_cell);
return;
}
@@ -12051,15 +12054,20 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
}
}
- Handle<WeakCell> code_cell = code->IsUndefined()
- ? isolate->factory()->empty_weak_cell()
- : isolate->factory()->NewWeakCell(code);
- Handle<WeakCell> literals_cell = isolate->factory()->NewWeakCell(literals);
WeakCell* context_cell = native_context->self_weak_cell();
-
new_code_map->set(entry + kContextOffset, context_cell);
- new_code_map->set(entry + kCachedCodeOffset, *code_cell);
+
+ bool created_new_map = !old_code_map.is_identical_to(new_code_map);
+ if (!code->IsUndefined() || created_new_map) {
+ Handle<WeakCell> code_cell = code->IsUndefined()
+ ? isolate->factory()->empty_weak_cell()
+ : isolate->factory()->NewWeakCell(code);
+ new_code_map->set(entry + kCachedCodeOffset, *code_cell);
+ }
+
+ Handle<WeakCell> literals_cell = isolate->factory()->NewWeakCell(literals);
new_code_map->set(entry + kLiteralsOffset, *literals_cell);
+
new_code_map->set(entry + kOsrAstIdOffset, Smi::FromInt(osr_ast_id.ToInt()));
#ifdef DEBUG
@@ -12076,8 +12084,7 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
}
#endif
- FixedArray* old_code_map = shared->optimized_code_map();
- if (old_code_map != *new_code_map) {
+ if (created_new_map) {
shared->set_optimized_code_map(*new_code_map);
}
}
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698