From 66f0df5a18cc5a0072fbbcecd71934b4d39d594b Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Fri, 25 Apr 2014 08:40:23 +0000 Subject: [PATCH] Added an Isolate* field to NoTrackDoubleFieldsForSerializerScope, PlatformFeatureScope and BinaryOpIC::State. The serializer state and even the CPU features will be per-Isolate later. Currently we get away with global state, because mksnapshot runs single-threaded and has only 1 Isolate, but this will change. Furthermore, these changes are yet another prerequisite for removing a catch-22 at initialization time when we try to enable serialization. This CL is similar in spirit to r20919, BTW. BUG=359977 LOG=y R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/250553005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20963 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/assembler.cc | 4 ++-- src/assembler.h | 3 ++- src/bootstrapper.cc | 6 ++++-- src/code-stubs.h | 2 +- src/ia32/builtins-ia32.cc | 2 +- src/ia32/code-stubs-ia32.cc | 2 +- src/ic.cc | 11 ++++++----- src/ic.h | 9 ++++++--- src/type-info.cc | 4 ++-- 9 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/assembler.cc b/src/assembler.cc index 6728ef4..148823c 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -213,8 +213,8 @@ CpuFeatureScope::~CpuFeatureScope() { // ----------------------------------------------------------------------------- // Implementation of PlatformFeatureScope -PlatformFeatureScope::PlatformFeatureScope(CpuFeature f) - : old_cross_compile_(CpuFeatures::cross_compile_) { +PlatformFeatureScope::PlatformFeatureScope(Isolate* isolate, CpuFeature f) + : isolate_(isolate), old_cross_compile_(CpuFeatures::cross_compile_) { // CpuFeatures is a global singleton, therefore this is only safe in // single threaded code. ASSERT(Serializer::enabled()); diff --git a/src/assembler.h b/src/assembler.h index 2742032..f818c36 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -158,10 +158,11 @@ class CpuFeatureScope BASE_EMBEDDED { // different CPU. class PlatformFeatureScope BASE_EMBEDDED { public: - explicit PlatformFeatureScope(CpuFeature f); + PlatformFeatureScope(Isolate* isolate, CpuFeature f); ~PlatformFeatureScope(); private: + Isolate* isolate_; uint64_t old_cross_compile_; }; diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index f99c852..6e2a237 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -2505,7 +2505,8 @@ void Genesis::MakeFunctionInstancePrototypeWritable() { class NoTrackDoubleFieldsForSerializerScope { public: - NoTrackDoubleFieldsForSerializerScope() : flag_(FLAG_track_double_fields) { + explicit NoTrackDoubleFieldsForSerializerScope(Isolate* isolate) + : isolate_(isolate), flag_(FLAG_track_double_fields) { if (Serializer::enabled()) { // Disable tracking double fields because heap numbers treated as // immutable by the serializer. @@ -2519,6 +2520,7 @@ class NoTrackDoubleFieldsForSerializerScope { } private: + Isolate* isolate_; bool flag_; }; @@ -2529,7 +2531,7 @@ Genesis::Genesis(Isolate* isolate, v8::ExtensionConfiguration* extensions) : isolate_(isolate), active_(isolate->bootstrapper()) { - NoTrackDoubleFieldsForSerializerScope disable_double_tracking_for_serializer; + NoTrackDoubleFieldsForSerializerScope disable_scope(isolate); result_ = Handle::null(); // If V8 cannot be initialized, just return. if (!V8::Initialize(NULL)) return; diff --git a/src/code-stubs.h b/src/code-stubs.h index 7280efc..f337137 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -1123,7 +1123,7 @@ class KeyedLoadFieldStub: public LoadFieldStub { class BinaryOpICStub : public HydrogenCodeStub { public: BinaryOpICStub(Isolate* isolate, Token::Value op, OverwriteMode mode) - : HydrogenCodeStub(isolate, UNINITIALIZED), state_(op, mode) {} + : HydrogenCodeStub(isolate, UNINITIALIZED), state_(isolate, op, mode) {} BinaryOpICStub(Isolate* isolate, const BinaryOpIC::State& state) : HydrogenCodeStub(isolate), state_(state) {} diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc index efef4a2..df30f7a 100644 --- a/src/ia32/builtins-ia32.cc +++ b/src/ia32/builtins-ia32.cc @@ -703,7 +703,7 @@ void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) { void Builtins::Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm) { if (Serializer::enabled()) { - PlatformFeatureScope sse2(SSE2); + PlatformFeatureScope sse2(masm->isolate(), SSE2); Generate_NotifyStubFailureHelper(masm, kSaveFPRegs); } else { Generate_NotifyStubFailureHelper(masm, kSaveFPRegs); diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index fe1c71d..fea5cbf 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -2517,7 +2517,7 @@ void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); CreateAllocationSiteStub::GenerateAheadOfTime(isolate); if (Serializer::enabled()) { - PlatformFeatureScope sse2(SSE2); + PlatformFeatureScope sse2(isolate, SSE2); BinaryOpICStub::GenerateAheadOfTime(isolate); BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); } else { diff --git a/src/ic.cc b/src/ic.cc index b82d0ce..442031f 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -2058,7 +2058,8 @@ RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss) { } -BinaryOpIC::State::State(ExtraICState extra_ic_state) { +BinaryOpIC::State::State(Isolate* isolate, ExtraICState extra_ic_state) + : isolate_(isolate) { // We don't deserialize the SSE2 Field, since this is only used to be able // to include SSE2 as well as non-SSE2 versions in the snapshot. For code // generation we always want it to reflect the current state. @@ -2109,7 +2110,7 @@ void BinaryOpIC::State::GenerateAheadOfTime( // Generated list of commonly used stubs #define GENERATE(op, left_kind, right_kind, result_kind, mode) \ do { \ - State state(op, mode); \ + State state(isolate, op, mode); \ state.left_kind_ = left_kind; \ state.fixed_right_arg_.has_value = false; \ state.right_kind_ = right_kind; \ @@ -2304,7 +2305,7 @@ void BinaryOpIC::State::GenerateAheadOfTime( #undef GENERATE #define GENERATE(op, left_kind, fixed_right_arg_value, result_kind, mode) \ do { \ - State state(op, mode); \ + State state(isolate, op, mode); \ state.left_kind_ = left_kind; \ state.fixed_right_arg_.has_value = true; \ state.fixed_right_arg_.value = fixed_right_arg_value; \ @@ -2482,7 +2483,7 @@ MaybeHandle BinaryOpIC::Transition( Handle allocation_site, Handle left, Handle right) { - State state(target()->extra_ic_state()); + State state(isolate(), target()->extra_ic_state()); // Compute the actual result using the builtin for the binary operation. Object* builtin = isolate()->js_builtins_object()->javascript_builtin( @@ -2499,7 +2500,7 @@ MaybeHandle BinaryOpIC::Transition( // update the state of this very IC, so we must update the stored state. UpdateTarget(); // Compute the new state. - State old_state(target()->extra_ic_state()); + State old_state(isolate(), target()->extra_ic_state()); state.Update(left, right, result); // Check if we have a string operation here. diff --git a/src/ic.h b/src/ic.h index dd6b609..8ab9972 100644 --- a/src/ic.h +++ b/src/ic.h @@ -743,11 +743,11 @@ class BinaryOpIC: public IC { public: class State V8_FINAL BASE_EMBEDDED { public: - explicit State(ExtraICState extra_ic_state); + State(Isolate* isolate, ExtraICState extra_ic_state); - State(Token::Value op, OverwriteMode mode) + State(Isolate* isolate, Token::Value op, OverwriteMode mode) : op_(op), mode_(mode), left_kind_(NONE), right_kind_(NONE), - result_kind_(NONE) { + result_kind_(NONE), isolate_(isolate) { ASSERT_LE(FIRST_TOKEN, op); ASSERT_LE(op, LAST_TOKEN); } @@ -824,6 +824,8 @@ class BinaryOpIC: public IC { Handle right, Handle result); + Isolate* isolate() const { return isolate_; } + private: enum Kind { NONE, SMI, INT32, NUMBER, STRING, GENERIC }; @@ -854,6 +856,7 @@ class BinaryOpIC: public IC { Kind right_kind_; Kind result_kind_; Maybe fixed_right_arg_; + Isolate* isolate_; }; explicit BinaryOpIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { } diff --git a/src/type-info.cc b/src/type-info.cc index 25141e7..f863af0 100644 --- a/src/type-info.cc +++ b/src/type-info.cc @@ -255,7 +255,7 @@ void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, } Handle code = Handle::cast(object); ASSERT_EQ(Code::BINARY_OP_IC, code->kind()); - BinaryOpIC::State state(code->extra_ic_state()); + BinaryOpIC::State state(isolate(), code->extra_ic_state()); ASSERT_EQ(op, state.op()); *left = state.GetLeftType(zone()); @@ -277,7 +277,7 @@ Type* TypeFeedbackOracle::CountType(TypeFeedbackId id) { if (!object->IsCode()) return Type::None(zone()); Handle code = Handle::cast(object); ASSERT_EQ(Code::BINARY_OP_IC, code->kind()); - BinaryOpIC::State state(code->extra_ic_state()); + BinaryOpIC::State state(isolate(), code->extra_ic_state()); return state.GetLeftType(zone()); } -- 2.7.4