Added an Isolate* field to NoTrackDoubleFieldsForSerializerScope,...

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
parent 79be5398
......@@ -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());
......
......@@ -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_;
};
......
......@@ -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<Context>::null();
// If V8 cannot be initialized, just return.
if (!V8::Initialize(NULL)) return;
......
......@@ -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) {}
......
......@@ -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);
......
......@@ -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 {
......
......@@ -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<Object> BinaryOpIC::Transition(
Handle<AllocationSite> allocation_site,
Handle<Object> left,
Handle<Object> 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<Object> 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.
......
......@@ -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<Object> right,
Handle<Object> 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<int> fixed_right_arg_;
Isolate* isolate_;
};
explicit BinaryOpIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { }
......
......@@ -255,7 +255,7 @@ void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
}
Handle<Code> code = Handle<Code>::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> code = Handle<Code>::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());
}
......
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