Reviewers: Michael Starzinger,
Description:
Reduced TLS accesses even further.
Thread the Isolate through FindCodeInCache, FindCodeInSpecialCache and
SetProperty. Reduced the number of TLS accesses while running the Octane
benchmark down to 19% compared to the beginning of the cleanups.
Please review this at https://codereview.chromium.org/11411033/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/api.cc
M src/code-stubs.h
M src/code-stubs.cc
M src/handles.h
M src/handles.cc
M src/ic.cc
M src/runtime-profiler.cc
M src/runtime.cc
M test/cctest/test-compiler.cc
M test/cctest/test-debug.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
3c4496055f772f83d67ebd925a21f671e0e00498..94f86146d3f98c137640afdd501b2077e8f2f7ac
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2860,6 +2860,7 @@ bool v8::Object::Set(v8::Handle<Value> key,
v8::Handle<Value> value,
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> obj = i::SetProperty(
+ isolate,
self,
key_obj,
value_obj,
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index
117b3b12d80094f97ebd71803ed1e3f043f6af33..276c87ebd00a227f162ed93cf81770ddcce05830
100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -37,11 +37,11 @@
namespace v8 {
namespace internal {
-bool CodeStub::FindCodeInCache(Code** code_out) {
- Heap* heap = Isolate::Current()->heap();
- int index = heap->code_stubs()->FindEntry(GetKey());
+bool CodeStub::FindCodeInCache(Code** code_out, Isolate* isolate) {
+ UnseededNumberDictionary* stubs = isolate->heap()->code_stubs();
+ int index = stubs->FindEntry(GetKey());
if (index != UnseededNumberDictionary::kNotFound) {
- *code_out = Code::cast(heap->code_stubs()->ValueAt(index));
+ *code_out = Code::cast(stubs->ValueAt(index));
return true;
}
return false;
@@ -93,8 +93,8 @@ Handle<Code> CodeStub::GetCode() {
Heap* heap = isolate->heap();
Code* code;
if (UseSpecialCache()
- ? FindCodeInSpecialCache(&code)
- : FindCodeInCache(&code)) {
+ ? FindCodeInSpecialCache(&code, isolate)
+ : FindCodeInCache(&code, isolate)) {
ASSERT(IsPregenerated() == code->is_pregenerated());
return Handle<Code>(code);
}
@@ -297,8 +297,7 @@ void ICCompareStub::AddToSpecialCache(Handle<Code>
new_object) {
}
-bool ICCompareStub::FindCodeInSpecialCache(Code** code_out) {
- Isolate* isolate = known_map_->GetIsolate();
+bool ICCompareStub::FindCodeInSpecialCache(Code** code_out, Isolate*
isolate) {
Factory* factory = isolate->factory();
Code::Flags flags = Code::ComputeFlags(
static_cast<Code::Kind>(GetCodeKind()),
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index
3110b54b996afbd6223c5f4ebc59492d93219593..ae113f5729a58d26bcdfeffff0ee5011a2570954
100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -141,7 +141,7 @@ class CodeStub BASE_EMBEDDED {
bool CompilingCallsToThisStubIsGCSafe() {
bool is_pregenerated = IsPregenerated();
Code* code = NULL;
- CHECK(!is_pregenerated || FindCodeInCache(&code));
+ CHECK(!is_pregenerated || FindCodeInCache(&code, Isolate::Current()));
return is_pregenerated;
}
@@ -160,7 +160,7 @@ class CodeStub BASE_EMBEDDED {
virtual bool SometimesSetsUpAFrame() { return true; }
// Lookup the code in the (possibly custom) cache.
- bool FindCodeInCache(Code** code_out);
+ bool FindCodeInCache(Code** code_out, Isolate* isolate);
protected:
static bool CanUseFPRegisters();
@@ -202,7 +202,9 @@ class CodeStub BASE_EMBEDDED {
virtual void AddToSpecialCache(Handle<Code> new_object) { }
// Find code in a specialized cache, work is delegated to the specific
stub.
- virtual bool FindCodeInSpecialCache(Code** code_out) { return false; }
+ virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate) {
+ return false;
+ }
// If a stub uses a special cache override this.
virtual bool UseSpecialCache() { return false; }
@@ -653,7 +655,7 @@ class ICCompareStub: public CodeStub {
Condition GetCondition() const { return
CompareIC::ComputeCondition(op_); }
virtual void AddToSpecialCache(Handle<Code> new_object);
- virtual bool FindCodeInSpecialCache(Code** code_out);
+ virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate);
virtual bool UseSpecialCache() { return state_ ==
CompareIC::KNOWN_OBJECTS; }
Token::Value op_;
Index: src/handles.cc
diff --git a/src/handles.cc b/src/handles.cc
index
a6192d8d6ea24b42b04c6405eb7b490e66b8f014..00213015d2b785031ba48459e7f766e867fa45be
100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -229,12 +229,12 @@ Handle<Object> SetPrototype(Handle<JSFunction>
function,
}
-Handle<Object> SetProperty(Handle<Object> object,
+Handle<Object> SetProperty(Isolate* isolate,
+ Handle<Object> object,
Handle<Object> key,
Handle<Object> value,
PropertyAttributes attributes,
StrictModeFlag strict_mode) {
- Isolate* isolate = Isolate::Current();
CALL_HEAP_FUNCTION(
isolate,
Runtime::SetObjectProperty(
Index: src/handles.h
diff --git a/src/handles.h b/src/handles.h
index
3b0d2f7ccf5eb11c262b1f9051ad00eb53c66102..032fbe48156c45c4380aaf1263c66470d6aa3380
100644
--- a/src/handles.h
+++ b/src/handles.h
@@ -216,7 +216,8 @@ Handle<String> FlattenGetString(Handle<String> str);
int Utf8Length(Handle<String> str);
-Handle<Object> SetProperty(Handle<Object> object,
+Handle<Object> SetProperty(Isolate* isolate,
+ Handle<Object> object,
Handle<Object> key,
Handle<Object> value,
PropertyAttributes attributes,
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index
5212004fa5a0532e35931aa20cf9e366d4f2e05d..bf2a649f7f298d1e53fb53b035b5dcfb323a7ee7
100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -2568,7 +2568,7 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) {
Code* CompareIC::GetRawUninitialized(Token::Value op) {
ICCompareStub stub(op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED);
Code* code = NULL;
- CHECK(stub.FindCodeInCache(&code));
+ CHECK(stub.FindCodeInCache(&code, Isolate::Current()));
return code;
}
Index: src/runtime-profiler.cc
diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc
index
5b2733356d243ce28dc366cafb66f08b37c9b10f..599e235c3925915fbb8f90bd5ed469d83290fb5b
100644
--- a/src/runtime-profiler.cc
+++ b/src/runtime-profiler.cc
@@ -200,11 +200,11 @@ void
RuntimeProfiler::AttemptOnStackReplacement(JSFunction* function) {
Code* stack_check_code = NULL;
if (FLAG_count_based_interrupts) {
InterruptStub interrupt_stub;
- found_code = interrupt_stub.FindCodeInCache(&stack_check_code);
+ found_code = interrupt_stub.FindCodeInCache(&stack_check_code,
isolate_);
} else // NOLINT
{ // NOLINT
StackCheckStub check_stub;
- found_code = check_stub.FindCodeInCache(&stack_check_code);
+ found_code = check_stub.FindCodeInCache(&stack_check_code, isolate_);
}
if (found_code) {
Code* replacement_code =
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
962889a7cbc6c080b039f0f6919eae4a2186bfbf..3f913fc280f1b15ba0a4ee05b88f705f6bbda958
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -10655,7 +10655,8 @@ static bool CopyContextLocalsToScopeObject(
RETURN_IF_EMPTY_HANDLE_VALUE(
isolate,
- SetProperty(scope_object,
+ SetProperty(isolate,
+ scope_object,
Handle<String>(scope_info->ContextLocalName(i)),
Handle<Object>(context->get(context_index), isolate),
NONE,
@@ -10690,7 +10691,8 @@ static Handle<JSObject>
MaterializeLocalScopeWithFrameInspector(
RETURN_IF_EMPTY_HANDLE_VALUE(
isolate,
- SetProperty(local_scope,
+ SetProperty(isolate,
+ local_scope,
Handle<String>(scope_info->ParameterName(i)),
value,
NONE,
@@ -10702,7 +10704,8 @@ static Handle<JSObject>
MaterializeLocalScopeWithFrameInspector(
for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
RETURN_IF_EMPTY_HANDLE_VALUE(
isolate,
- SetProperty(local_scope,
+ SetProperty(isolate,
+ local_scope,
Handle<String>(scope_info->StackLocalName(i)),
Handle<Object>(frame_inspector->GetExpression(i)),
NONE,
@@ -10736,7 +10739,8 @@ static Handle<JSObject>
MaterializeLocalScopeWithFrameInspector(
Handle<String> key(String::cast(keys->get(i)));
RETURN_IF_EMPTY_HANDLE_VALUE(
isolate,
- SetProperty(local_scope,
+ SetProperty(isolate,
+ local_scope,
key,
GetProperty(ext, key),
NONE,
@@ -10797,7 +10801,8 @@ static Handle<JSObject> MaterializeClosure(Isolate*
isolate,
Handle<String> key(String::cast(keys->get(i)));
RETURN_IF_EMPTY_HANDLE_VALUE(
isolate,
- SetProperty(closure_scope,
+ SetProperty(isolate,
+ closure_scope,
key,
GetProperty(ext, key),
NONE,
@@ -10821,7 +10826,12 @@ static Handle<JSObject>
MaterializeCatchScope(Isolate* isolate,
isolate->factory()->NewJSObject(isolate->object_function());
RETURN_IF_EMPTY_HANDLE_VALUE(
isolate,
- SetProperty(catch_scope, name, thrown_object, NONE, kNonStrictMode),
+ SetProperty(isolate,
+ catch_scope,
+ name,
+ thrown_object,
+ NONE,
+ kNonStrictMode),
Handle<JSObject>());
return catch_scope;
}
Index: test/cctest/test-compiler.cc
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index
7700a980d2fd0b84232133c2ffc5eea4545ac653..807adbf7f401d7c8f43dd4551ec204492bc514ea
100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -100,10 +100,11 @@ static MaybeObject* GetGlobalProperty(const char*
name) {
static void SetGlobalProperty(const char* name, Object* value) {
+ Isolate* isolate = Isolate::Current();
Handle<Object> object(value);
Handle<String> symbol = FACTORY->LookupAsciiSymbol(name);
Handle<JSObject> global(Isolate::Current()->context()->global_object());
- SetProperty(global, symbol, object, NONE, kNonStrictMode);
+ SetProperty(isolate, global, symbol, object, NONE, kNonStrictMode);
}
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index
a719a62a373684f7c5528b32fc3938de91023551..941fa688d5af146926731d605cccc08dc2cb0a7d
100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -146,7 +146,8 @@ class DebugLocalContext {
inline v8::Context* operator*() { return *context_; }
inline bool IsReady() { return !context_.IsEmpty(); }
void ExposeDebug() {
- v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
+ v8::internal::Isolate* isolate = v8::internal::Isolate::Current();
+ v8::internal::Debug* debug = isolate->debug();
// Expose the debug context global object in the global object for
testing.
debug->Load();
debug->debug_context()->set_security_token(
@@ -156,7 +157,7 @@ class DebugLocalContext {
v8::Utils::OpenHandle(*context_->Global())));
Handle<v8::internal::String> debug_string =
FACTORY->LookupAsciiSymbol("debug");
- SetProperty(global, debug_string,
+ SetProperty(isolate, global, debug_string,
Handle<Object>(debug->debug_context()->global_proxy()), DONT_ENUM,
::v8::internal::kNonStrictMode);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev