Commit 815d8237 authored by franzih's avatar franzih Committed by Commit bot

[object] Add Script::IsUserJavaScript().

Extract script->type() == TYPE_NORMAL into
a function.

BUG=

Review-Url: https://codereview.chromium.org/2744613006
Cr-Commit-Position: refs/heads/master@{#43868}
parent 7de21c4d
......@@ -9406,7 +9406,7 @@ void debug::GetLoadedScripts(v8::Isolate* v8_isolate,
i::Script::Iterator iterator(isolate);
i::Script* script;
while ((script = iterator.Next())) {
if (script->type() != i::Script::TYPE_NORMAL) continue;
if (!script->IsUserJavaScript()) continue;
if (script->HasValidSource()) {
i::HandleScope handle_scope(isolate);
i::Handle<i::Script> script_handle(script, isolate);
......
......@@ -485,8 +485,8 @@ bool Renumber(ParseInfo* parse_info,
bool collect_type_profile;
if (parse_info->shared_info().is_null() ||
parse_info->shared_info()->feedback_metadata()->length() == 0) {
collect_type_profile = FLAG_type_profile &&
parse_info->script()->type() == Script::TYPE_NORMAL;
collect_type_profile =
FLAG_type_profile && parse_info->script()->IsUserJavaScript();
} else {
collect_type_profile =
parse_info->shared_info()->feedback_metadata()->HasTypeProfileSlot();
......
......@@ -94,8 +94,7 @@ Coverage* Coverage::Collect(Isolate* isolate, bool reset_count) {
Coverage* result = new Coverage();
Script::Iterator scripts(isolate);
while (Script* script = scripts.Next()) {
// Dismiss non-user scripts.
if (script->type() != Script::TYPE_NORMAL) continue;
if (!script->IsUserJavaScript()) continue;
// Create and add new script data.
Handle<Script> script_handle(script, isolate);
......
......@@ -1979,7 +1979,7 @@ bool Debug::IsBlackboxed(Handle<SharedFunctionInfo> shared) {
DisableBreak no_recursive_break(this);
DCHECK(shared->script()->IsScript());
Handle<Script> script(Script::cast(shared->script()));
DCHECK(script->type() == i::Script::TYPE_NORMAL);
DCHECK(script->IsUserJavaScript());
debug::Location start =
GetDebugLocation(script, shared->start_position());
debug::Location end = GetDebugLocation(script, shared->end_position());
......@@ -2030,8 +2030,7 @@ void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) {
FixedArray* array = isolate_->native_context()->embedder_data();
script->set_context_data(array->get(v8::Context::kDebugIdIndex));
if (ignore_events()) return;
if (script->type() != i::Script::TYPE_NORMAL &&
script->type() != i::Script::TYPE_WASM) {
if (!script->IsUserJavaScript() && script->type() != i::Script::TYPE_WASM) {
return;
}
if (!debug_delegate_) return;
......
......@@ -740,7 +740,7 @@ Handle<Object> AsmJsWasmStackFrame::GetFunction() const {
Handle<Object> AsmJsWasmStackFrame::GetFileName() {
Handle<Script> script =
wasm::GetScript(Handle<JSObject>::cast(wasm_instance_));
DCHECK_EQ(Script::TYPE_NORMAL, script->type());
DCHECK(script->IsUserJavaScript());
return handle(script->name(), isolate_);
}
......@@ -766,7 +766,7 @@ int AsmJsWasmStackFrame::GetLineNumber() {
DCHECK_LE(0, GetPosition());
Handle<Script> script =
wasm::GetScript(Handle<JSObject>::cast(wasm_instance_));
DCHECK_EQ(Script::TYPE_NORMAL, script->type());
DCHECK(script->IsUserJavaScript());
return Script::GetLineNumber(script, GetPosition()) + 1;
}
......@@ -774,7 +774,7 @@ int AsmJsWasmStackFrame::GetColumnNumber() {
DCHECK_LE(0, GetPosition());
Handle<Script> script =
wasm::GetScript(Handle<JSObject>::cast(wasm_instance_));
DCHECK_EQ(Script::TYPE_NORMAL, script->type());
DCHECK(script->IsUserJavaScript());
return Script::GetColumnNumber(script, GetPosition()) + 1;
}
......
......@@ -6325,7 +6325,7 @@ bool SharedFunctionInfo::IsUserJavaScript() {
Object* script_obj = script();
if (script_obj->IsUndefined(GetIsolate())) return false;
Script* script = Script::cast(script_obj);
return static_cast<Script::Type>(script->type()) == Script::TYPE_NORMAL;
return script->IsUserJavaScript();
}
bool SharedFunctionInfo::IsSubjectToDebugging() {
......
......@@ -13073,6 +13073,8 @@ bool Script::GetPositionInfo(Handle<Script> script, int position,
return script->GetPositionInfo(position, info, offset_flag);
}
bool Script::IsUserJavaScript() { return type() == Script::TYPE_NORMAL; }
namespace {
bool GetPositionInfoSlow(const Script* script, int position,
Script::PositionInfo* info) {
......
......@@ -6687,6 +6687,8 @@ class Script: public Struct {
bool GetPositionInfo(int position, PositionInfo* info,
OffsetFlag offset_flag) const;
bool IsUserJavaScript();
// Wrappers for GetPositionInfo
static int GetColumnNumber(Handle<Script> script, int code_offset);
int GetColumnNumber(int code_pos) const;
......
......@@ -580,7 +580,7 @@ Handle<WasmSharedModuleData> WasmSharedModuleData::New(
bool WasmSharedModuleData::is_asm_js() {
bool asm_js = module()->origin == wasm::ModuleOrigin::kAsmJsOrigin;
DCHECK_EQ(asm_js, script()->type() == Script::TYPE_NORMAL);
DCHECK_EQ(asm_js, script()->IsUserJavaScript());
DCHECK_EQ(asm_js, has_asm_js_offset_table());
return asm_js;
}
......
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