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.

Review URL: https://codereview.chromium.org/11411033

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13030 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ee164ffe
......@@ -2857,6 +2857,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,
......
......@@ -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()),
......
......@@ -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_;
......
......@@ -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(
......
......@@ -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,
......
......@@ -2559,7 +2559,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;
}
......
......@@ -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 =
......
......@@ -10639,7 +10639,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,
......@@ -10674,7 +10675,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,
......@@ -10686,7 +10688,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,
......@@ -10720,7 +10723,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,
......@@ -10781,7 +10785,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,
......@@ -10805,7 +10810,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;
}
......
......@@ -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);
}
......
......@@ -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);
}
......
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