Remove easy to remove calls to Isolate::Current() from api.cc

R=vogelheim@chromium.org
LOG=n
BUG=v8:2487

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

Cr-Commit-Position: refs/heads/master@{#32389}
This commit is contained in:
jochen 2015-11-30 00:16:35 -08:00 committed by Commit bot
parent 4a54378e57
commit 7730edcc12
19 changed files with 103 additions and 211 deletions

View File

@ -39,7 +39,7 @@ class V8_EXPORT Testing {
/**
* Force deoptimization of all functions.
*/
static void DeoptimizeAll();
static void DeoptimizeAll(Isolate* isolate);
};

View File

@ -3932,7 +3932,8 @@ class V8_EXPORT NumberObject : public Object {
*/
class V8_EXPORT BooleanObject : public Object {
public:
static Local<Value> New(bool value);
static Local<Value> New(Isolate* isolate, bool value);
V8_DEPRECATE_SOON("Pass an isolate", static Local<Value> New(bool value));
bool ValueOf() const;
@ -4583,7 +4584,7 @@ class V8_EXPORT ObjectTemplate : public Template {
static Local<ObjectTemplate> New(
Isolate* isolate,
Local<FunctionTemplate> constructor = Local<FunctionTemplate>());
static V8_DEPRECATE_SOON("Use isolate version", Local<ObjectTemplate> New());
static V8_DEPRECATED("Use isolate version", Local<ObjectTemplate> New());
/** Creates a new instance of this template.*/
V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance());
@ -4771,21 +4772,6 @@ class V8_EXPORT AccessorSignature : public Data {
};
/**
* A utility for determining the type of objects based on the template
* they were constructed from.
*/
class V8_EXPORT TypeSwitch : public Data {
public:
static Local<TypeSwitch> New(Local<FunctionTemplate> type);
static Local<TypeSwitch> New(int argc, Local<FunctionTemplate> types[]);
int match(Local<Value> value);
private:
TypeSwitch();
};
// --- Extensions ---
class V8_EXPORT ExternalOneByteStringResourceImpl
@ -6179,7 +6165,7 @@ class V8_EXPORT V8 {
* register the same callback function two times with different
* GCType filters.
*/
static V8_DEPRECATE_SOON(
static V8_DEPRECATED(
"Use isolate version",
void AddGCPrologueCallback(GCCallback callback,
GCType gc_type_filter = kGCTypeAll));
@ -6188,7 +6174,7 @@ class V8_EXPORT V8 {
* This function removes callback which was installed by
* AddGCPrologueCallback function.
*/
V8_INLINE static V8_DEPRECATE_SOON(
V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void RemoveGCPrologueCallback(GCCallback callback));
@ -6202,7 +6188,7 @@ class V8_EXPORT V8 {
* register the same callback function two times with different
* GCType filters.
*/
static V8_DEPRECATE_SOON(
static V8_DEPRECATED(
"Use isolate version",
void AddGCEpilogueCallback(GCCallback callback,
GCType gc_type_filter = kGCTypeAll));
@ -6211,7 +6197,7 @@ class V8_EXPORT V8 {
* This function removes callback which was installed by
* AddGCEpilogueCallback function.
*/
V8_INLINE static V8_DEPRECATE_SOON(
V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void RemoveGCEpilogueCallback(GCCallback callback));

View File

@ -1069,41 +1069,6 @@ Local<AccessorSignature> AccessorSignature::New(
}
Local<TypeSwitch> TypeSwitch::New(Local<FunctionTemplate> type) {
Local<FunctionTemplate> types[1] = {type};
return TypeSwitch::New(1, types);
}
Local<TypeSwitch> TypeSwitch::New(int argc, Local<FunctionTemplate> types[]) {
i::Isolate* isolate = i::Isolate::Current();
LOG_API(isolate, "TypeSwitch::New");
ENTER_V8(isolate);
i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc);
for (int i = 0; i < argc; i++)
vector->set(i, *Utils::OpenHandle(*types[i]));
i::Handle<i::Struct> struct_obj =
isolate->factory()->NewStruct(i::TYPE_SWITCH_INFO_TYPE);
i::Handle<i::TypeSwitchInfo> obj =
i::Handle<i::TypeSwitchInfo>::cast(struct_obj);
obj->set_types(*vector);
return Utils::ToLocal(obj);
}
int TypeSwitch::match(v8::Local<Value> value) {
i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this);
LOG_API(info->GetIsolate(), "TypeSwitch::match");
i::Handle<i::Object> obj = Utils::OpenHandle(*value);
i::FixedArray* types = i::FixedArray::cast(info->types());
for (int i = 0; i < types->length(); i++) {
if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj))
return i + 1;
}
return 0;
}
#define SET_FIELD_WRAPPED(obj, setter, cdata) do { \
i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \
(obj)->setter(*foreign); \
@ -6027,20 +5992,24 @@ double v8::NumberObject::ValueOf() const {
}
Local<v8::Value> v8::BooleanObject::New(bool value) {
i::Isolate* isolate = i::Isolate::Current();
LOG_API(isolate, "BooleanObject::New");
ENTER_V8(isolate);
i::Handle<i::Object> boolean(value
? isolate->heap()->true_value()
: isolate->heap()->false_value(),
isolate);
Local<v8::Value> v8::BooleanObject::New(Isolate* isolate, bool value) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, "BooleanObject::New");
ENTER_V8(i_isolate);
i::Handle<i::Object> boolean(value ? i_isolate->heap()->true_value()
: i_isolate->heap()->false_value(),
i_isolate);
i::Handle<i::Object> obj =
i::Object::ToObject(isolate, boolean).ToHandleChecked();
i::Object::ToObject(i_isolate, boolean).ToHandleChecked();
return Utils::ToLocal(obj);
}
Local<v8::Value> v8::BooleanObject::New(bool value) {
return New(Isolate::GetCurrent(), value);
}
bool v8::BooleanObject::ValueOf() const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
@ -7887,8 +7856,8 @@ MaybeLocal<Array> Debug::GetInternalProperties(Isolate* v8_isolate,
Local<String> CpuProfileNode::GetFunctionName() const {
i::Isolate* isolate = i::Isolate::Current();
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
i::Isolate* isolate = node->isolate();
const i::CodeEntry* entry = node->entry();
i::Handle<i::String> name =
isolate->factory()->InternalizeUtf8String(entry->name());
@ -7912,8 +7881,8 @@ int CpuProfileNode::GetScriptId() const {
Local<String> CpuProfileNode::GetScriptResourceName() const {
i::Isolate* isolate = i::Isolate::Current();
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
i::Isolate* isolate = node->isolate();
return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
node->entry()->resource_name()));
}
@ -7983,16 +7952,17 @@ const std::vector<CpuProfileDeoptInfo>& CpuProfileNode::GetDeoptInfos() const {
void CpuProfile::Delete() {
i::Isolate* isolate = i::Isolate::Current();
i::CpuProfile* profile = reinterpret_cast<i::CpuProfile*>(this);
i::Isolate* isolate = profile->top_down()->isolate();
i::CpuProfiler* profiler = isolate->cpu_profiler();
DCHECK(profiler != NULL);
profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
profiler->DeleteProfile(profile);
}
Local<String> CpuProfile::GetTitle() const {
i::Isolate* isolate = i::Isolate::Current();
const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
i::Isolate* isolate = profile->top_down()->isolate();
return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
profile->title()));
}
@ -8079,8 +8049,8 @@ HeapGraphEdge::Type HeapGraphEdge::GetType() const {
Local<Value> HeapGraphEdge::GetName() const {
i::Isolate* isolate = i::Isolate::Current();
i::HeapGraphEdge* edge = ToInternal(this);
i::Isolate* isolate = edge->isolate();
switch (edge->type()) {
case i::HeapGraphEdge::kContextVariable:
case i::HeapGraphEdge::kInternal:
@ -8123,7 +8093,7 @@ HeapGraphNode::Type HeapGraphNode::GetType() const {
Local<String> HeapGraphNode::GetName() const {
i::Isolate* isolate = i::Isolate::Current();
i::Isolate* isolate = ToInternal(this)->isolate();
return ToApiHandle<String>(
isolate->factory()->InternalizeUtf8String(ToInternal(this)->name()));
}
@ -8157,7 +8127,7 @@ static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
void HeapSnapshot::Delete() {
i::Isolate* isolate = i::Isolate::Current();
i::Isolate* isolate = ToInternal(this)->profiler()->isolate();
if (isolate->heap_profiler()->GetSnapshotsCount() > 1) {
ToInternal(this)->Delete();
} else {
@ -8353,11 +8323,10 @@ void Testing::PrepareStressRun(int run) {
}
// TODO(svenpanne) Deprecate this.
void Testing::DeoptimizeAll() {
i::Isolate* isolate = i::Isolate::Current();
i::HandleScope scope(isolate);
internal::Deoptimizer::DeoptimizeAll(isolate);
void Testing::DeoptimizeAll(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::HandleScope scope(i_isolate);
internal::Deoptimizer::DeoptimizeAll(i_isolate);
}

View File

@ -142,7 +142,6 @@ class RegisteredExtension {
V(ObjectTemplate, ObjectTemplateInfo) \
V(Signature, FunctionTemplateInfo) \
V(AccessorSignature, FunctionTemplateInfo) \
V(TypeSwitch, TypeSwitchInfo) \
V(Data, Object) \
V(RegExp, JSRegExp) \
V(Object, JSReceiver) \
@ -265,8 +264,6 @@ class Utils {
v8::internal::Handle<v8::internal::FunctionTemplateInfo> obj);
static inline Local<AccessorSignature> AccessorSignatureToLocal(
v8::internal::Handle<v8::internal::FunctionTemplateInfo> obj);
static inline Local<TypeSwitch> ToLocal(
v8::internal::Handle<v8::internal::TypeSwitchInfo> obj);
static inline Local<External> ExternalToLocal(
v8::internal::Handle<v8::internal::JSObject> obj);
static inline Local<NativeWeakMap> NativeWeakMapToLocal(
@ -375,7 +372,6 @@ MAKE_TO_LOCAL(ToLocal, FunctionTemplateInfo, FunctionTemplate)
MAKE_TO_LOCAL(ToLocal, ObjectTemplateInfo, ObjectTemplate)
MAKE_TO_LOCAL(SignatureToLocal, FunctionTemplateInfo, Signature)
MAKE_TO_LOCAL(AccessorSignatureToLocal, FunctionTemplateInfo, AccessorSignature)
MAKE_TO_LOCAL(ToLocal, TypeSwitchInfo, TypeSwitch)
MAKE_TO_LOCAL(MessageToLocal, Object, Message)
MAKE_TO_LOCAL(PromiseToLocal, JSObject, Promise)
MAKE_TO_LOCAL(StackTraceToLocal, JSArray, StackTrace)

View File

@ -2479,7 +2479,7 @@ int Shell::Main(int argc, char* argv[]) {
result = RunMain(isolate, argc, argv, last_run);
}
printf("======== Full Deoptimization =======\n");
Testing::DeoptimizeAll();
Testing::DeoptimizeAll(isolate);
#if !defined(V8_SHARED)
} else if (i::FLAG_stress_runs > 0) {
options.stress_runs = i::FLAG_stress_runs;

View File

@ -968,12 +968,6 @@ void ObjectTemplateInfo::ObjectTemplateInfoVerify() {
}
void TypeSwitchInfo::TypeSwitchInfoVerify() {
CHECK(IsTypeSwitchInfo());
VerifyPointer(types());
}
void AllocationSite::AllocationSiteVerify() {
CHECK(IsAllocationSite());
}

View File

@ -5623,8 +5623,6 @@ ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset)
ACCESSORS(ObjectTemplateInfo, internal_field_count, Object,
kInternalFieldCountOffset)
ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset)
ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset)
ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset)
SMI_ACCESSORS(AllocationSite, pretenure_data, kPretenureDataOffset)

View File

@ -1081,13 +1081,6 @@ void ObjectTemplateInfo::ObjectTemplateInfoPrint(std::ostream& os) { // NOLINT
}
void TypeSwitchInfo::TypeSwitchInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "TypeSwitchInfo");
os << "\n - types: " << Brief(types());
os << "\n";
}
void AllocationSite::AllocationSitePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "AllocationSite");
os << " - weak_next: " << Brief(weak_next());

View File

@ -144,7 +144,6 @@
// - FunctionTemplateInfo
// - ObjectTemplateInfo
// - Script
// - TypeSwitchInfo
// - DebugInfo
// - BreakPointInfo
// - CodeCache
@ -514,7 +513,6 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \
V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \
V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \
V(SCRIPT, Script, script) \
V(ALLOCATION_SITE, AllocationSite, allocation_site) \
V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \
@ -10500,21 +10498,6 @@ class ObjectTemplateInfo: public TemplateInfo {
};
class TypeSwitchInfo: public Struct {
public:
DECL_ACCESSORS(types, Object)
DECLARE_CAST(TypeSwitchInfo)
// Dispatched behavior.
DECLARE_PRINTER(TypeSwitchInfo)
DECLARE_VERIFIER(TypeSwitchInfo)
static const int kTypesOffset = Struct::kHeaderSize;
static const int kSize = kTypesOffset + kPointerSize;
};
// The DebugInfo class holds additional information for a function being
// debugged.
class DebugInfo: public Struct {

View File

@ -66,6 +66,8 @@ class HeapProfiler {
Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
void ClearHeapObjectMap();
Isolate* isolate() const { return heap()->isolate(); }
private:
Heap* heap() const;

View File

@ -16,6 +16,11 @@ HeapEntry* HeapGraphEdge::from() const {
}
Isolate* HeapGraphEdge::isolate() const {
return snapshot()->profiler()->isolate();
}
HeapSnapshot* HeapGraphEdge::snapshot() const {
return to_entry_->snapshot();
}
@ -43,6 +48,8 @@ HeapGraphEdge** HeapEntry::children_arr() {
}
Isolate* HeapEntry::isolate() const { return snapshot_->profiler()->isolate(); }
} // namespace internal
} // namespace v8

View File

@ -50,6 +50,8 @@ class HeapGraphEdge BASE_EMBEDDED {
INLINE(HeapEntry* from() const);
HeapEntry* to() const { return to_entry_; }
INLINE(Isolate* isolate() const);
private:
INLINE(HeapSnapshot* snapshot() const);
int from_index() const { return FromIndexField::decode(bit_field_); }
@ -115,6 +117,7 @@ class HeapEntry BASE_EMBEDDED {
}
Vector<HeapGraphEdge*> children() {
return Vector<HeapGraphEdge*>(children_arr(), children_count_); }
INLINE(Isolate* isolate() const);
void SetIndexedReference(
HeapGraphEdge::Type type, int index, HeapEntry* entry);

View File

@ -42,6 +42,10 @@ ProfileNode::ProfileNode(ProfileTree* tree, CodeEntry* entry)
inline unsigned ProfileNode::function_id() const {
return tree_->GetFunctionId(this);
}
inline Isolate* ProfileNode::isolate() const { return tree_->isolate(); }
} // namespace internal
} // namespace v8

View File

@ -249,10 +249,11 @@ class DeleteNodesCallback {
};
ProfileTree::ProfileTree()
ProfileTree::ProfileTree(Isolate* isolate)
: root_entry_(Logger::FUNCTION_TAG, "(root)"),
next_node_id_(1),
root_(new ProfileNode(this, &root_entry_)),
isolate_(isolate),
next_function_id_(1),
function_ids_(ProfileNode::CodeEntriesMatch) {}
@ -347,11 +348,11 @@ void ProfileTree::TraverseDepthFirst(Callback* callback) {
}
CpuProfile::CpuProfile(const char* title, bool record_samples)
CpuProfile::CpuProfile(Isolate* isolate, const char* title, bool record_samples)
: title_(title),
record_samples_(record_samples),
start_time_(base::TimeTicks::HighResolutionNow()) {
}
start_time_(base::TimeTicks::HighResolutionNow()),
top_down_(isolate) {}
void CpuProfile::AddPath(base::TimeTicks timestamp,
@ -440,8 +441,8 @@ void CodeMap::Print() {
CpuProfilesCollection::CpuProfilesCollection(Heap* heap)
: function_and_resource_names_(heap),
current_profiles_semaphore_(1) {
}
isolate_(heap->isolate()),
current_profiles_semaphore_(1) {}
static void DeleteCodeEntry(CodeEntry** entry_ptr) {
@ -476,7 +477,7 @@ bool CpuProfilesCollection::StartProfiling(const char* title,
return true;
}
}
current_profiles_.Add(new CpuProfile(title, record_samples));
current_profiles_.Add(new CpuProfile(isolate_, title, record_samples));
current_profiles_semaphore_.Signal();
return true;
}

View File

@ -156,6 +156,7 @@ class ProfileNode {
const std::vector<CpuProfileDeoptInfo>& deopt_infos() const {
return deopt_infos_;
}
Isolate* isolate() const;
void Print(int indent);
@ -186,7 +187,7 @@ class ProfileNode {
class ProfileTree {
public:
ProfileTree();
explicit ProfileTree(Isolate* isolate);
~ProfileTree();
ProfileNode* AddPathFromEnd(
@ -200,6 +201,8 @@ class ProfileTree {
root_->Print(0);
}
Isolate* isolate() const { return isolate_; }
private:
template <typename Callback>
void TraverseDepthFirst(Callback* callback);
@ -207,6 +210,7 @@ class ProfileTree {
CodeEntry root_entry_;
unsigned next_node_id_;
ProfileNode* root_;
Isolate* isolate_;
unsigned next_function_id_;
HashMap function_ids_;
@ -217,7 +221,7 @@ class ProfileTree {
class CpuProfile {
public:
CpuProfile(const char* title, bool record_samples);
CpuProfile(Isolate* isolate, const char* title, bool record_samples);
// Add pc -> ... -> main() call path to the profile.
void AddPath(base::TimeTicks timestamp, const Vector<CodeEntry*>& path,
@ -339,6 +343,8 @@ class CpuProfilesCollection {
List<CodeEntry*> code_entries_;
List<CpuProfile*> finished_profiles_;
Isolate* isolate_;
// Accessed by VM thread and profile generator thread.
List<CpuProfile*> current_profiles_;
base::Semaphore current_profiles_semaphore_;

View File

@ -1724,8 +1724,10 @@ THREADED_TEST(BooleanObject) {
CHECK(!as_boxed.IsEmpty());
bool the_boolean = as_boxed->ValueOf();
CHECK_EQ(true, the_boolean);
v8::Local<v8::Value> boxed_true = v8::BooleanObject::New(true);
v8::Local<v8::Value> boxed_false = v8::BooleanObject::New(false);
v8::Local<v8::Value> boxed_true =
v8::BooleanObject::New(env->GetIsolate(), true);
v8::Local<v8::Value> boxed_false =
v8::BooleanObject::New(env->GetIsolate(), false);
CHECK(boxed_true->IsBooleanObject());
CHECK(boxed_false->IsBooleanObject());
as_boxed = boxed_true.As<v8::BooleanObject>();
@ -1746,7 +1748,7 @@ THREADED_TEST(PrimitiveAndWrappedBooleans) {
CHECK(!primitive_false->IsTrue());
CHECK(primitive_false->IsFalse());
Local<Value> false_value = BooleanObject::New(false);
Local<Value> false_value = BooleanObject::New(env->GetIsolate(), false);
CHECK(!false_value->IsBoolean());
CHECK(false_value->IsBooleanObject());
CHECK(false_value->BooleanValue(env.local()).FromJust());
@ -1768,7 +1770,7 @@ THREADED_TEST(PrimitiveAndWrappedBooleans) {
CHECK(primitive_true->IsTrue());
CHECK(!primitive_true->IsFalse());
Local<Value> true_value = BooleanObject::New(true);
Local<Value> true_value = BooleanObject::New(env->GetIsolate(), true);
CHECK(!true_value->IsBoolean());
CHECK(true_value->IsBooleanObject());
CHECK(true_value->BooleanValue(env.local()).FromJust());
@ -8702,41 +8704,6 @@ THREADED_TEST(DeleteAccessor) {
}
THREADED_TEST(TypeSwitch) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Local<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate);
v8::Local<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate);
v8::Local<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate);
v8::Local<v8::FunctionTemplate> templs[3] = {templ1, templ2, templ3};
v8::Local<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs);
LocalContext context;
v8::Local<v8::Object> obj0 = v8::Object::New(isolate);
v8::Local<v8::Object> obj1 = templ1->GetFunction(context.local())
.ToLocalChecked()
->NewInstance(context.local())
.ToLocalChecked();
v8::Local<v8::Object> obj2 = templ2->GetFunction(context.local())
.ToLocalChecked()
->NewInstance(context.local())
.ToLocalChecked();
v8::Local<v8::Object> obj3 = templ3->GetFunction(context.local())
.ToLocalChecked()
->NewInstance(context.local())
.ToLocalChecked();
for (int i = 0; i < 10; i++) {
CHECK_EQ(0, type_switch->match(obj0));
CHECK_EQ(1, type_switch->match(obj1));
CHECK_EQ(2, type_switch->match(obj2));
CHECK_EQ(3, type_switch->match(obj3));
CHECK_EQ(3, type_switch->match(obj3));
CHECK_EQ(2, type_switch->match(obj2));
CHECK_EQ(1, type_switch->match(obj1));
CHECK_EQ(0, type_switch->match(obj0));
}
}
static int trouble_nesting = 0;
static void TroubleCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
@ -14741,11 +14708,12 @@ class RegExpInterruptionThread : public v8::base::Thread {
};
void RunBeforeGC(v8::GCType type, v8::GCCallbackFlags flags) {
void RunBeforeGC(v8::Isolate* isolate, v8::GCType type,
v8::GCCallbackFlags flags) {
if (v8::base::NoBarrier_Load(&regexp_interruption_data.loop_count) != 2) {
return;
}
v8::HandleScope scope(CcTest::isolate());
v8::HandleScope scope(isolate);
v8::Local<v8::String> string = v8::Local<v8::String>::New(
CcTest::isolate(), regexp_interruption_data.string);
string->MakeExternal(regexp_interruption_data.string_resource);
@ -14762,7 +14730,7 @@ TEST(RegExpInterruption) {
RegExpInterruptionThread timeout_thread(CcTest::isolate());
v8::V8::AddGCPrologueCallback(RunBeforeGC);
env->GetIsolate()->AddGCPrologueCallback(RunBeforeGC);
static const char* one_byte_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
i::uc16* uc16_content = AsciiToTwoByteString(one_byte_content);
v8::Local<v8::String> string = v8_str(one_byte_content);
@ -18091,12 +18059,6 @@ int epilogue_call_count_second = 0;
int prologue_call_count_alloc = 0;
int epilogue_call_count_alloc = 0;
void PrologueCallback(v8::GCType, v8::GCCallbackFlags flags) {
CHECK_EQ(flags, v8::kNoGCCallbackFlags);
++prologue_call_count;
}
void PrologueCallback(v8::Isolate* isolate,
v8::GCType,
v8::GCCallbackFlags flags) {
@ -18105,13 +18067,6 @@ void PrologueCallback(v8::Isolate* isolate,
++prologue_call_count;
}
void EpilogueCallback(v8::GCType, v8::GCCallbackFlags flags) {
CHECK_EQ(flags, v8::kNoGCCallbackFlags);
++epilogue_call_count;
}
void EpilogueCallback(v8::Isolate* isolate,
v8::GCType,
v8::GCCallbackFlags flags) {
@ -18121,12 +18076,6 @@ void EpilogueCallback(v8::Isolate* isolate,
}
void PrologueCallbackSecond(v8::GCType, v8::GCCallbackFlags flags) {
CHECK_EQ(flags, v8::kNoGCCallbackFlags);
++prologue_call_count_second;
}
void PrologueCallbackSecond(v8::Isolate* isolate,
v8::GCType,
v8::GCCallbackFlags flags) {
@ -18136,12 +18085,6 @@ void PrologueCallbackSecond(v8::Isolate* isolate,
}
void EpilogueCallbackSecond(v8::GCType, v8::GCCallbackFlags flags) {
CHECK_EQ(flags, v8::kNoGCCallbackFlags);
++epilogue_call_count_second;
}
void EpilogueCallbackSecond(v8::Isolate* isolate,
v8::GCType,
v8::GCCallbackFlags flags) {
@ -18194,29 +18137,31 @@ void EpilogueCallbackAlloc(v8::Isolate* isolate,
TEST(GCCallbacksOld) {
LocalContext context;
v8::V8::AddGCPrologueCallback(PrologueCallback);
v8::V8::AddGCEpilogueCallback(EpilogueCallback);
gc_callbacks_isolate = context->GetIsolate();
context->GetIsolate()->AddGCPrologueCallback(PrologueCallback);
context->GetIsolate()->AddGCEpilogueCallback(EpilogueCallback);
CHECK_EQ(0, prologue_call_count);
CHECK_EQ(0, epilogue_call_count);
CcTest::heap()->CollectAllGarbage();
CHECK_EQ(1, prologue_call_count);
CHECK_EQ(1, epilogue_call_count);
v8::V8::AddGCPrologueCallback(PrologueCallbackSecond);
v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond);
context->GetIsolate()->AddGCPrologueCallback(PrologueCallbackSecond);
context->GetIsolate()->AddGCEpilogueCallback(EpilogueCallbackSecond);
CcTest::heap()->CollectAllGarbage();
CHECK_EQ(2, prologue_call_count);
CHECK_EQ(2, epilogue_call_count);
CHECK_EQ(1, prologue_call_count_second);
CHECK_EQ(1, epilogue_call_count_second);
v8::V8::RemoveGCPrologueCallback(PrologueCallback);
v8::V8::RemoveGCEpilogueCallback(EpilogueCallback);
context->GetIsolate()->RemoveGCPrologueCallback(PrologueCallback);
context->GetIsolate()->RemoveGCEpilogueCallback(EpilogueCallback);
CcTest::heap()->CollectAllGarbage();
CHECK_EQ(2, prologue_call_count);
CHECK_EQ(2, epilogue_call_count);
CHECK_EQ(2, prologue_call_count_second);
CHECK_EQ(2, epilogue_call_count_second);
v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond);
v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond);
context->GetIsolate()->RemoveGCPrologueCallback(PrologueCallbackSecond);
context->GetIsolate()->RemoveGCEpilogueCallback(EpilogueCallbackSecond);
CcTest::heap()->CollectAllGarbage();
CHECK_EQ(2, prologue_call_count);
CHECK_EQ(2, epilogue_call_count);

View File

@ -1539,7 +1539,8 @@ class GraphWithImplicitRefs {
instance_ = NULL;
}
static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) {
static void gcPrologue(v8::Isolate* isolate, v8::GCType type,
v8::GCCallbackFlags flags) {
instance_->AddImplicitReferences();
}
@ -1571,7 +1572,7 @@ TEST(HeapSnapshotImplicitReferences) {
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
GraphWithImplicitRefs graph(&env);
v8::V8::AddGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
env->GetIsolate()->AddGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
CHECK(ValidateSnapshot(snapshot));
@ -1594,7 +1595,8 @@ TEST(HeapSnapshotImplicitReferences) {
}
}
CHECK_EQ(2, implicit_targets_count);
v8::V8::RemoveGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
env->GetIsolate()->RemoveGCPrologueCallback(
&GraphWithImplicitRefs::gcPrologue);
}

View File

@ -51,7 +51,8 @@ using i::Vector;
TEST(ProfileNodeFindOrAddChild) {
ProfileTree tree;
CcTest::InitializeVM();
ProfileTree tree(CcTest::i_isolate());
ProfileNode* node = tree.root();
CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa");
ProfileNode* childNode1 = node->FindOrAddChild(&entry1);
@ -75,8 +76,9 @@ TEST(ProfileNodeFindOrAddChild) {
TEST(ProfileNodeFindOrAddChildForSameFunction) {
CcTest::InitializeVM();
const char* aaa = "aaa";
ProfileTree tree;
ProfileTree tree(CcTest::i_isolate());
ProfileNode* node = tree.root();
CodeEntry entry1(i::Logger::FUNCTION_TAG, aaa);
ProfileNode* childNode1 = node->FindOrAddChild(&entry1);
@ -122,10 +124,11 @@ class ProfileTreeTestHelper {
TEST(ProfileTreeAddPathFromEnd) {
CcTest::InitializeVM();
CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa");
CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb");
CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc");
ProfileTree tree;
ProfileTree tree(CcTest::i_isolate());
ProfileTreeTestHelper helper(&tree);
CHECK(!helper.Walk(&entry1));
CHECK(!helper.Walk(&entry2));
@ -181,7 +184,8 @@ TEST(ProfileTreeAddPathFromEnd) {
TEST(ProfileTreeCalculateTotalTicks) {
ProfileTree empty_tree;
CcTest::InitializeVM();
ProfileTree empty_tree(CcTest::i_isolate());
CHECK_EQ(0u, empty_tree.root()->self_ticks());
empty_tree.root()->IncrementSelfTicks();
CHECK_EQ(1u, empty_tree.root()->self_ticks());
@ -191,7 +195,7 @@ TEST(ProfileTreeCalculateTotalTicks) {
Vector<CodeEntry*> e1_path_vec(
e1_path, sizeof(e1_path) / sizeof(e1_path[0]));
ProfileTree single_child_tree;
ProfileTree single_child_tree(CcTest::i_isolate());
single_child_tree.AddPathFromEnd(e1_path_vec);
single_child_tree.root()->IncrementSelfTicks();
CHECK_EQ(1u, single_child_tree.root()->self_ticks());
@ -206,7 +210,7 @@ TEST(ProfileTreeCalculateTotalTicks) {
Vector<CodeEntry*> e2_e1_path_vec(e2_e1_path,
sizeof(e2_e1_path) / sizeof(e2_e1_path[0]));
ProfileTree flat_tree;
ProfileTree flat_tree(CcTest::i_isolate());
ProfileTreeTestHelper flat_helper(&flat_tree);
flat_tree.AddPathFromEnd(e1_path_vec);
flat_tree.AddPathFromEnd(e1_path_vec);
@ -233,7 +237,7 @@ TEST(ProfileTreeCalculateTotalTicks) {
Vector<CodeEntry*> e3_path_vec(
e3_path, sizeof(e3_path) / sizeof(e3_path[0]));
ProfileTree wide_tree;
ProfileTree wide_tree(CcTest::i_isolate());
ProfileTreeTestHelper wide_helper(&wide_tree);
wide_tree.AddPathFromEnd(e1_path_vec);
wide_tree.AddPathFromEnd(e1_path_vec);

View File

@ -231,7 +231,6 @@ KNOWN_MAPS = {
0x098e9: (165, "CallHandlerInfoMap"),
0x09915: (166, "FunctionTemplateInfoMap"),
0x09941: (167, "ObjectTemplateInfoMap"),
0x0996d: (169, "TypeSwitchInfoMap"),
0x09999: (173, "CodeCacheMap"),
0x099c5: (175, "TypeFeedbackInfoMap"),
0x099f1: (176, "AliasedArgumentsEntryMap"),