Commit 4b8f6543 authored by hablich's avatar hablich Committed by Commit bot

Revert of [inspector] fixed all shorten-64-to-32 warnings (patchset #4...

Revert of [inspector] fixed all shorten-64-to-32 warnings (patchset #4 id:80001 of https://codereview.chromium.org/2332163002/ )

Reason for revert:
Blocking V8 roll: https://codereview.chromium.org/2347463002/

See https://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/293368 for compile error.

Original issue's description:
> [inspector] fixed all shorten-64-to-32 warnings
>
> BUG=chromium:635948
> R=dgozman@chromium.org,alph@chromium.org
>
> Committed: https://crrev.com/3d10918d2e1c57d72531c55a956262f5a72fceaa
> Cr-Commit-Position: refs/heads/master@{#39426}

TBR=jochen@chromium.org,alph@chromium.org,dgozman@chromium.org,kozyatinskiy@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:635948

Review-Url: https://codereview.chromium.org/2339173004
Cr-Commit-Position: refs/heads/master@{#39432}
parent cb891cb0
...@@ -37,14 +37,14 @@ class V8_EXPORT StringView { ...@@ -37,14 +37,14 @@ class V8_EXPORT StringView {
public: public:
StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {} StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {}
StringView(const uint8_t* characters, size_t length) StringView(const uint8_t* characters, unsigned length)
: m_is8Bit(true), m_length(length), m_characters8(characters) {} : m_is8Bit(true), m_length(length), m_characters8(characters) {}
StringView(const uint16_t* characters, size_t length) StringView(const uint16_t* characters, unsigned length)
: m_is8Bit(false), m_length(length), m_characters16(characters) {} : m_is8Bit(false), m_length(length), m_characters16(characters) {}
bool is8Bit() const { return m_is8Bit; } bool is8Bit() const { return m_is8Bit; }
size_t length() const { return m_length; } unsigned length() const { return m_length; }
// TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used // TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used
// here. // here.
...@@ -53,7 +53,7 @@ class V8_EXPORT StringView { ...@@ -53,7 +53,7 @@ class V8_EXPORT StringView {
private: private:
bool m_is8Bit; bool m_is8Bit;
size_t m_length; unsigned m_length;
union { union {
const uint8_t* m_characters8; const uint8_t* m_characters8;
const uint16_t* m_characters16; const uint16_t* m_characters16;
......
...@@ -376,8 +376,8 @@ InjectedScript::createExceptionDetails(ErrorString* errorString, ...@@ -376,8 +376,8 @@ InjectedScript::createExceptionDetails(ErrorString* errorString,
: message->GetStartColumn(m_context->context()).FromMaybe(0)) : message->GetStartColumn(m_context->context()).FromMaybe(0))
.build(); .build();
if (!message.IsEmpty()) { if (!message.IsEmpty()) {
exceptionDetails->setScriptId(String16::fromInteger( exceptionDetails->setScriptId(
static_cast<int>(message->GetScriptOrigin().ScriptID()->Value()))); String16::fromInteger(message->GetScriptOrigin().ScriptID()->Value()));
v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace(); v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace();
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
exceptionDetails->setStackTrace(m_context->inspector() exceptionDetails->setStackTrace(m_context->inspector()
......
...@@ -16,8 +16,8 @@ namespace { ...@@ -16,8 +16,8 @@ namespace {
String16 findMagicComment(const String16& content, const String16& name, String16 findMagicComment(const String16& content, const String16& name,
bool multiline) { bool multiline) {
DCHECK(name.find("=") == String16::kNotFound); DCHECK(name.find("=") == String16::kNotFound);
size_t length = content.length(); unsigned length = content.length();
size_t nameLength = name.length(); unsigned nameLength = name.length();
size_t pos = length; size_t pos = length;
size_t equalSignPos = 0; size_t equalSignPos = 0;
...@@ -56,7 +56,7 @@ String16 findMagicComment(const String16& content, const String16& name, ...@@ -56,7 +56,7 @@ String16 findMagicComment(const String16& content, const String16& name,
if (newLine != String16::kNotFound) match = match.substring(0, newLine); if (newLine != String16::kNotFound) match = match.substring(0, newLine);
match = match.stripWhiteSpace(); match = match.stripWhiteSpace();
for (size_t i = 0; i < match.length(); ++i) { for (unsigned i = 0; i < match.length(); ++i) {
UChar c = match[i]; UChar c = match[i];
if (c == '"' || c == '\'' || c == ' ' || c == '\t') return ""; if (c == '"' || c == '\'' || c == ' ' || c == '\t') return "";
} }
...@@ -67,7 +67,7 @@ String16 findMagicComment(const String16& content, const String16& name, ...@@ -67,7 +67,7 @@ String16 findMagicComment(const String16& content, const String16& name,
String16 createSearchRegexSource(const String16& text) { String16 createSearchRegexSource(const String16& text) {
String16Builder result; String16Builder result;
for (size_t i = 0; i < text.length(); i++) { for (unsigned i = 0; i < text.length(); i++) {
UChar c = text[i]; UChar c = text[i];
if (c == '[' || c == ']' || c == '(' || c == ')' || c == '{' || c == '}' || if (c == '[' || c == ']' || c == '(' || c == ')' || c == '{' || c == '}' ||
c == '+' || c == '-' || c == '*' || c == '.' || c == ',' || c == '?' || c == '+' || c == '-' || c == '*' || c == '.' || c == ',' || c == '?' ||
...@@ -80,19 +80,19 @@ String16 createSearchRegexSource(const String16& text) { ...@@ -80,19 +80,19 @@ String16 createSearchRegexSource(const String16& text) {
return result.toString(); return result.toString();
} }
std::unique_ptr<std::vector<size_t>> lineEndings(const String16& text) { std::unique_ptr<std::vector<unsigned>> lineEndings(const String16& text) {
std::unique_ptr<std::vector<size_t>> result(new std::vector<size_t>()); std::unique_ptr<std::vector<unsigned>> result(new std::vector<unsigned>());
const String16 lineEndString = "\n"; const String16 lineEndString = "\n";
size_t start = 0; unsigned start = 0;
while (start < text.length()) { while (start < text.length()) {
size_t lineEnd = text.find(lineEndString, start); size_t lineEnd = text.find(lineEndString, start);
if (lineEnd == String16::kNotFound) break; if (lineEnd == String16::kNotFound) break;
result->push_back(lineEnd); result->push_back(static_cast<unsigned>(lineEnd));
start = lineEnd + 1; start = lineEnd + 1;
} }
result->push_back(text.length()); result->push_back(static_cast<unsigned>(text.length()));
return result; return result;
} }
...@@ -102,11 +102,11 @@ std::vector<std::pair<int, String16>> scriptRegexpMatchesByLines( ...@@ -102,11 +102,11 @@ std::vector<std::pair<int, String16>> scriptRegexpMatchesByLines(
std::vector<std::pair<int, String16>> result; std::vector<std::pair<int, String16>> result;
if (text.isEmpty()) return result; if (text.isEmpty()) return result;
std::unique_ptr<std::vector<size_t>> endings(lineEndings(text)); std::unique_ptr<std::vector<unsigned>> endings(lineEndings(text));
size_t size = endings->size(); unsigned size = endings->size();
size_t start = 0; unsigned start = 0;
for (size_t lineNumber = 0; lineNumber < size; ++lineNumber) { for (unsigned lineNumber = 0; lineNumber < size; ++lineNumber) {
size_t lineEnd = endings->at(lineNumber); unsigned lineEnd = endings->at(lineNumber);
String16 line = text.substring(start, lineEnd - start); String16 line = text.substring(start, lineEnd - start);
if (line.length() && line[line.length() - 1] == '\r') if (line.length() && line[line.length() - 1] == '\r')
line = line.substring(0, line.length() - 1); line = line.substring(0, line.length() - 1);
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <cctype> #include <cctype>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <limits>
#include <locale> #include <locale>
#include <string> #include <string>
...@@ -39,12 +38,9 @@ int charactersToInteger(const UChar* characters, size_t length, ...@@ -39,12 +38,9 @@ int charactersToInteger(const UChar* characters, size_t length,
buffer.push_back('\0'); buffer.push_back('\0');
char* endptr; char* endptr;
long result = std::strtol(buffer.data(), &endptr, 10); int result = std::strtol(buffer.data(), &endptr, 10);
if (ok) { if (ok) *ok = !(*endptr);
*ok = !(*endptr) && result <= std::numeric_limits<int>::max() && return result;
result >= std::numeric_limits<int>::min();
}
return static_cast<int>(result);
} }
const UChar replacementCharacter = 0xFFFD; const UChar replacementCharacter = 0xFFFD;
...@@ -253,7 +249,7 @@ static const UChar32 offsetsFromUTF8[6] = {0x00000000UL, ...@@ -253,7 +249,7 @@ static const UChar32 offsetsFromUTF8[6] = {0x00000000UL,
static_cast<UChar32>(0xFA082080UL), static_cast<UChar32>(0xFA082080UL),
static_cast<UChar32>(0x82082080UL)}; static_cast<UChar32>(0x82082080UL)};
static inline UChar32 readUTF8Sequence(const char*& sequence, size_t length) { static inline UChar32 readUTF8Sequence(const char*& sequence, unsigned length) {
UChar32 character = 0; UChar32 character = 0;
// The cases all fall through. // The cases all fall through.
...@@ -370,14 +366,6 @@ String16 String16::fromInteger(int number) { ...@@ -370,14 +366,6 @@ String16 String16::fromInteger(int number) {
return String16(buffer); return String16(buffer);
} }
// static
String16 String16::fromInteger(size_t number) {
const size_t kBufferSize = 50;
char buffer[kBufferSize];
std::snprintf(buffer, kBufferSize, "%zu", number);
return String16(buffer);
}
// static // static
String16 String16::fromDouble(double number) { String16 String16::fromDouble(double number) {
const size_t kBufferSize = 100; const size_t kBufferSize = 100;
...@@ -409,8 +397,8 @@ int String16::toInteger(bool* ok) const { ...@@ -409,8 +397,8 @@ int String16::toInteger(bool* ok) const {
String16 String16::stripWhiteSpace() const { String16 String16::stripWhiteSpace() const {
if (!length()) return String16(); if (!length()) return String16();
size_t start = 0; unsigned start = 0;
size_t end = length() - 1; unsigned end = length() - 1;
// skip white space from start // skip white space from start
while (start <= end && isSpaceOrNewLine(characters16()[start])) ++start; while (start <= end && isSpaceOrNewLine(characters16()[start])) ++start;
...@@ -468,12 +456,12 @@ String16 String16::fromUTF8(const char* stringStart, size_t length) { ...@@ -468,12 +456,12 @@ String16 String16::fromUTF8(const char* stringStart, size_t length) {
true) != conversionOK) true) != conversionOK)
return String16(); return String16();
size_t utf16Length = bufferCurrent - bufferStart; unsigned utf16Length = bufferCurrent - bufferStart;
return String16(bufferStart, utf16Length); return String16(bufferStart, utf16Length);
} }
std::string String16::utf8() const { std::string String16::utf8() const {
size_t length = this->length(); unsigned length = this->length();
if (!length) return std::string(""); if (!length) return std::string("");
......
...@@ -32,7 +32,6 @@ class String16 { ...@@ -32,7 +32,6 @@ class String16 {
} }
static String16 fromInteger(int); static String16 fromInteger(int);
static String16 fromInteger(size_t);
static String16 fromDouble(double); static String16 fromDouble(double);
static String16 fromDoublePrecision3(double); static String16 fromDoublePrecision3(double);
static String16 fromDoublePrecision6(double); static String16 fromDoublePrecision6(double);
...@@ -42,14 +41,14 @@ class String16 { ...@@ -42,14 +41,14 @@ class String16 {
const UChar* characters16() const { return m_impl.c_str(); } const UChar* characters16() const { return m_impl.c_str(); }
size_t length() const { return m_impl.length(); } size_t length() const { return m_impl.length(); }
bool isEmpty() const { return !m_impl.length(); } bool isEmpty() const { return !m_impl.length(); }
UChar operator[](size_t index) const { return m_impl[index]; } UChar operator[](unsigned index) const { return m_impl[index]; }
String16 substring(size_t pos, size_t len = UINT_MAX) const { String16 substring(unsigned pos, unsigned len = UINT_MAX) const {
return String16(m_impl.substr(pos, len)); return String16(m_impl.substr(pos, len));
} }
size_t find(const String16& str, size_t start = 0) const { size_t find(const String16& str, unsigned start = 0) const {
return m_impl.find(str.m_impl, start); return m_impl.find(str.m_impl, start);
} }
size_t reverseFind(const String16& str, size_t start = UINT_MAX) const { size_t reverseFind(const String16& str, unsigned start = UINT_MAX) const {
return m_impl.rfind(str.m_impl, start); return m_impl.rfind(str.m_impl, start);
} }
void swap(String16& other) { m_impl.swap(other.m_impl); } void swap(String16& other) { m_impl.swap(other.m_impl); }
......
...@@ -6,27 +6,22 @@ ...@@ -6,27 +6,22 @@
#include "src/inspector/protocol/Protocol.h" #include "src/inspector/protocol/Protocol.h"
#include <limits>
namespace v8_inspector { namespace v8_inspector {
v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String16& string) { v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String16& string) {
if (string.isEmpty()) return v8::String::Empty(isolate); if (string.isEmpty()) return v8::String::Empty(isolate);
DCHECK(string.length() < v8::String::kMaxLength);
return v8::String::NewFromTwoByte( return v8::String::NewFromTwoByte(
isolate, reinterpret_cast<const uint16_t*>(string.characters16()), isolate, reinterpret_cast<const uint16_t*>(string.characters16()),
v8::NewStringType::kNormal, static_cast<int>(string.length())) v8::NewStringType::kNormal, string.length())
.ToLocalChecked(); .ToLocalChecked();
} }
v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate, v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate,
const String16& string) { const String16& string) {
if (string.isEmpty()) return v8::String::Empty(isolate); if (string.isEmpty()) return v8::String::Empty(isolate);
DCHECK(string.length() < v8::String::kMaxLength);
return v8::String::NewFromTwoByte( return v8::String::NewFromTwoByte(
isolate, reinterpret_cast<const uint16_t*>(string.characters16()), isolate, reinterpret_cast<const uint16_t*>(string.characters16()),
v8::NewStringType::kInternalized, v8::NewStringType::kInternalized, string.length())
static_cast<int>(string.length()))
.ToLocalChecked(); .ToLocalChecked();
} }
...@@ -39,15 +34,14 @@ v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate, ...@@ -39,15 +34,14 @@ v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate,
v8::Local<v8::String> toV8String(v8::Isolate* isolate, v8::Local<v8::String> toV8String(v8::Isolate* isolate,
const StringView& string) { const StringView& string) {
if (!string.length()) return v8::String::Empty(isolate); if (!string.length()) return v8::String::Empty(isolate);
DCHECK(string.length() < v8::String::kMaxLength);
if (string.is8Bit()) if (string.is8Bit())
return v8::String::NewFromOneByte( return v8::String::NewFromOneByte(
isolate, reinterpret_cast<const uint8_t*>(string.characters8()), isolate, reinterpret_cast<const uint8_t*>(string.characters8()),
v8::NewStringType::kNormal, static_cast<int>(string.length())) v8::NewStringType::kNormal, string.length())
.ToLocalChecked(); .ToLocalChecked();
return v8::String::NewFromTwoByte( return v8::String::NewFromTwoByte(
isolate, reinterpret_cast<const uint16_t*>(string.characters16()), isolate, reinterpret_cast<const uint16_t*>(string.characters16()),
v8::NewStringType::kNormal, static_cast<int>(string.length())) v8::NewStringType::kNormal, string.length())
.ToLocalChecked(); .ToLocalChecked();
} }
...@@ -97,20 +91,14 @@ namespace protocol { ...@@ -97,20 +91,14 @@ namespace protocol {
std::unique_ptr<protocol::Value> parseJSON(const StringView& string) { std::unique_ptr<protocol::Value> parseJSON(const StringView& string) {
if (!string.length()) return nullptr; if (!string.length()) return nullptr;
DCHECK(string.length() <= std::numeric_limits<int>::max()); if (string.is8Bit())
if (string.is8Bit()) { return protocol::parseJSON(string.characters8(), string.length());
return protocol::parseJSON(string.characters8(), return protocol::parseJSON(string.characters16(), string.length());
static_cast<int>(string.length()));
}
return protocol::parseJSON(string.characters16(),
static_cast<int>(string.length()));
} }
std::unique_ptr<protocol::Value> parseJSON(const String16& string) { std::unique_ptr<protocol::Value> parseJSON(const String16& string) {
if (!string.length()) return nullptr; if (!string.length()) return nullptr;
DCHECK(string.length() <= std::numeric_limits<int>::max()); return protocol::parseJSON(string.characters16(), string.length());
return protocol::parseJSON(string.characters16(),
static_cast<int>(string.length()));
} }
} // namespace protocol } // namespace protocol
......
...@@ -21,16 +21,13 @@ using StringBuilder = v8_inspector::String16Builder; ...@@ -21,16 +21,13 @@ using StringBuilder = v8_inspector::String16Builder;
class StringUtil { class StringUtil {
public: public:
static String substring(const String& s, size_t pos, size_t len) { static String substring(const String& s, unsigned pos, unsigned len) {
return s.substring(pos, len); return s.substring(pos, len);
} }
static String fromInteger(int number) { return String::fromInteger(number); } static String fromInteger(int number) { return String::fromInteger(number); }
static String fromInteger(size_t number) {
return String::fromInteger(number);
}
static String fromDouble(double number) { return String::fromDouble(number); } static String fromDouble(double number) { return String::fromDouble(number); }
static const size_t kNotFound = String::kNotFound; static const size_t kNotFound = String::kNotFound;
static void builderReserve(StringBuilder& builder, size_t capacity) { static void builderReserve(StringBuilder& builder, unsigned capacity) {
builder.reserveCapacity(capacity); builder.reserveCapacity(capacity);
} }
}; };
......
...@@ -160,16 +160,16 @@ class ConsoleHelper { ...@@ -160,16 +160,16 @@ class ConsoleHelper {
: v8::MaybeLocal<v8::Map>(); : v8::MaybeLocal<v8::Map>();
} }
int32_t getIntFromMap(v8::Local<v8::Map> map, const String16& key, int64_t getIntFromMap(v8::Local<v8::Map> map, const String16& key,
int32_t defaultValue) { int64_t defaultValue) {
v8::Local<v8::String> v8Key = toV8String(m_isolate, key); v8::Local<v8::String> v8Key = toV8String(m_isolate, key);
if (!map->Has(m_context, v8Key).FromMaybe(false)) return defaultValue; if (!map->Has(m_context, v8Key).FromMaybe(false)) return defaultValue;
v8::Local<v8::Value> intValue; v8::Local<v8::Value> intValue;
if (!map->Get(m_context, v8Key).ToLocal(&intValue)) return defaultValue; if (!map->Get(m_context, v8Key).ToLocal(&intValue)) return defaultValue;
return static_cast<int32_t>(intValue.As<v8::Integer>()->Value()); return intValue.As<v8::Integer>()->Value();
} }
void setIntOnMap(v8::Local<v8::Map> map, const String16& key, int32_t value) { void setIntOnMap(v8::Local<v8::Map> map, const String16& key, int64_t value) {
v8::Local<v8::String> v8Key = toV8String(m_isolate, key); v8::Local<v8::String> v8Key = toV8String(m_isolate, key);
if (!map->Set(m_context, v8Key, v8::Integer::New(m_isolate, value)) if (!map->Set(m_context, v8Key, v8::Integer::New(m_isolate, value))
.ToLocal(&map)) .ToLocal(&map))
...@@ -353,7 +353,7 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { ...@@ -353,7 +353,7 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Map> countMap; v8::Local<v8::Map> countMap;
if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap)) return; if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap)) return;
int32_t count = helper.getIntFromMap(countMap, identifier, 0) + 1; int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1;
helper.setIntOnMap(countMap, identifier, count); helper.setIntOnMap(countMap, identifier, count);
helper.reportCallWithArgument(ConsoleAPIType::kCount, helper.reportCallWithArgument(ConsoleAPIType::kCount,
title + ": " + String16::fromInteger(count)); title + ": " + String16::fromInteger(count));
...@@ -511,7 +511,7 @@ void V8Console::valuesCallback( ...@@ -511,7 +511,7 @@ void V8Console::valuesCallback(
v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (!obj->GetOwnPropertyNames(context).ToLocal(&names)) return; if (!obj->GetOwnPropertyNames(context).ToLocal(&names)) return;
v8::Local<v8::Array> values = v8::Array::New(isolate, names->Length()); v8::Local<v8::Array> values = v8::Array::New(isolate, names->Length());
for (uint32_t i = 0; i < names->Length(); ++i) { for (size_t i = 0; i < names->Length(); ++i) {
v8::Local<v8::Value> key; v8::Local<v8::Value> key;
if (!names->Get(context, i).ToLocal(&key)) continue; if (!names->Get(context, i).ToLocal(&key)) continue;
v8::Local<v8::Value> value; v8::Local<v8::Value> value;
...@@ -876,7 +876,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope( ...@@ -876,7 +876,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope(
if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return; if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return;
v8::Local<v8::External> externalThis = v8::Local<v8::External> externalThis =
v8::External::New(context->GetIsolate(), this); v8::External::New(context->GetIsolate(), this);
for (uint32_t i = 0; i < names->Length(); ++i) { for (size_t i = 0; i < names->Length(); ++i) {
v8::Local<v8::Value> name; v8::Local<v8::Value> name;
if (!names->Get(context, i).ToLocal(&name) || !name->IsName()) continue; if (!names->Get(context, i).ToLocal(&name) || !name->IsName()) continue;
if (m_global->Has(context, name).FromMaybe(true)) continue; if (m_global->Has(context, name).FromMaybe(true)) continue;
...@@ -899,7 +899,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope( ...@@ -899,7 +899,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope(
V8Console::CommandLineAPIScope::~CommandLineAPIScope() { V8Console::CommandLineAPIScope::~CommandLineAPIScope() {
m_cleanup = true; m_cleanup = true;
v8::Local<v8::Array> names = m_installedMethods->AsArray(); v8::Local<v8::Array> names = m_installedMethods->AsArray();
for (uint32_t i = 0; i < names->Length(); ++i) { for (size_t i = 0; i < names->Length(); ++i) {
v8::Local<v8::Value> name; v8::Local<v8::Value> name;
if (!names->Get(m_context, i).ToLocal(&name) || !name->IsName()) continue; if (!names->Get(m_context, i).ToLocal(&name) || !name->IsName()) continue;
if (name->IsString()) { if (name->IsString()) {
......
...@@ -378,13 +378,9 @@ bool V8Debugger::setScriptSource( ...@@ -378,13 +378,9 @@ bool V8Debugger::setScriptSource(
.setExceptionId(m_inspector->nextExceptionId()) .setExceptionId(m_inspector->nextExceptionId())
.setText(toProtocolStringWithTypeCheck(resultTuple->Get(2))) .setText(toProtocolStringWithTypeCheck(resultTuple->Get(2)))
.setLineNumber( .setLineNumber(
static_cast<int>( resultTuple->Get(3)->ToInteger(m_isolate)->Value() - 1)
resultTuple->Get(3)->ToInteger(m_isolate)->Value()) -
1)
.setColumnNumber( .setColumnNumber(
static_cast<int>( resultTuple->Get(4)->ToInteger(m_isolate)->Value() - 1)
resultTuple->Get(4)->ToInteger(m_isolate)->Value()) -
1)
.build(); .build();
return false; return false;
} }
...@@ -416,7 +412,7 @@ JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) { ...@@ -416,7 +412,7 @@ JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) {
if (!currentCallFramesV8->IsArray()) return JavaScriptCallFrames(); if (!currentCallFramesV8->IsArray()) return JavaScriptCallFrames();
v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>(); v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>();
JavaScriptCallFrames callFrames; JavaScriptCallFrames callFrames;
for (uint32_t i = 0; i < callFramesArray->Length(); ++i) { for (size_t i = 0; i < callFramesArray->Length(); ++i) {
v8::Local<v8::Value> callFrameValue; v8::Local<v8::Value> callFrameValue;
if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue)) if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue))
return JavaScriptCallFrames(); return JavaScriptCallFrames();
...@@ -462,7 +458,7 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, ...@@ -462,7 +458,7 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
std::vector<String16> breakpointIds; std::vector<String16> breakpointIds;
if (!hitBreakpointNumbers.IsEmpty()) { if (!hitBreakpointNumbers.IsEmpty()) {
breakpointIds.reserve(hitBreakpointNumbers->Length()); breakpointIds.reserve(hitBreakpointNumbers->Length());
for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get(i); v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get(i);
DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt32()); DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt32());
breakpointIds.push_back( breakpointIds.push_back(
...@@ -583,9 +579,9 @@ void V8Debugger::handleV8AsyncTaskEvent(v8::Local<v8::Context> context, ...@@ -583,9 +579,9 @@ void V8Debugger::handleV8AsyncTaskEvent(v8::Local<v8::Context> context,
callInternalGetterFunction(eventData, "type")); callInternalGetterFunction(eventData, "type"));
String16 name = toProtocolStringWithTypeCheck( String16 name = toProtocolStringWithTypeCheck(
callInternalGetterFunction(eventData, "name")); callInternalGetterFunction(eventData, "name"));
int id = static_cast<int>(callInternalGetterFunction(eventData, "id") int id = callInternalGetterFunction(eventData, "id")
->ToInteger(m_isolate) ->ToInteger(m_isolate)
->Value()); ->Value();
// The scopes for the ids are defined by the eventData.name namespaces. There // The scopes for the ids are defined by the eventData.name namespaces. There
// are currently two namespaces: "Object." and "Promise.". // are currently two namespaces: "Object." and "Promise.".
void* ptr = reinterpret_cast<void*>(id * 4 + (name[0] == 'P' ? 2 : 0) + 1); void* ptr = reinterpret_cast<void*>(id * 4 + (name[0] == 'P' ? 2 : 0) + 1);
......
...@@ -934,7 +934,7 @@ std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames( ...@@ -934,7 +934,7 @@ std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(
: nullptr; : nullptr;
String16 callFrameId = String16 callFrameId =
RemoteCallFrameId::serialize(contextId, static_cast<int>(frameOrdinal)); RemoteCallFrameId::serialize(contextId, frameOrdinal);
if (hasInternalError( if (hasInternalError(
errorString, errorString,
!details !details
...@@ -1006,11 +1006,9 @@ std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames( ...@@ -1006,11 +1006,9 @@ std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(
return Array<CallFrame>::create(); return Array<CallFrame>::create();
} }
if (hasInternalError( if (hasInternalError(errorString,
errorString, !objects->Set(debuggerContext, frameOrdinal, details)
!objects .FromMaybe(false)))
->Set(debuggerContext, static_cast<int>(frameOrdinal), details)
.FromMaybe(false)))
return Array<CallFrame>::create(); return Array<CallFrame>::create();
} }
......
...@@ -11,7 +11,7 @@ namespace v8_inspector { ...@@ -11,7 +11,7 @@ namespace v8_inspector {
static const char hexDigits[17] = "0123456789ABCDEF"; static const char hexDigits[17] = "0123456789ABCDEF";
static void appendUnsignedAsHex(uint64_t number, String16Builder* destination) { static void appendUnsignedAsHex(unsigned number, String16Builder* destination) {
for (size_t i = 0; i < 8; ++i) { for (size_t i = 0; i < 8; ++i) {
UChar c = hexDigits[number & 0xF]; UChar c = hexDigits[number & 0xF];
destination->append(c); destination->append(c);
...@@ -81,28 +81,24 @@ V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate, ...@@ -81,28 +81,24 @@ V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate,
object->Get(toV8StringInternalized(isolate, "sourceURL"))); object->Get(toV8StringInternalized(isolate, "sourceURL")));
m_sourceMappingURL = toProtocolStringWithTypeCheck( m_sourceMappingURL = toProtocolStringWithTypeCheck(
object->Get(toV8StringInternalized(isolate, "sourceMappingURL"))); object->Get(toV8StringInternalized(isolate, "sourceMappingURL")));
m_startLine = m_startLine = object->Get(toV8StringInternalized(isolate, "startLine"))
static_cast<int>(object->Get(toV8StringInternalized(isolate, "startLine")) ->ToInteger(isolate)
->ToInteger(isolate) ->Value();
->Value()); m_startColumn = object->Get(toV8StringInternalized(isolate, "startColumn"))
m_startColumn = static_cast<int>( ->ToInteger(isolate)
object->Get(toV8StringInternalized(isolate, "startColumn")) ->Value();
->ToInteger(isolate) m_endLine = object->Get(toV8StringInternalized(isolate, "endLine"))
->Value()); ->ToInteger(isolate)
m_endLine = ->Value();
static_cast<int>(object->Get(toV8StringInternalized(isolate, "endLine")) m_endColumn = object->Get(toV8StringInternalized(isolate, "endColumn"))
->ToInteger(isolate) ->ToInteger(isolate)
->Value()); ->Value();
m_endColumn =
static_cast<int>(object->Get(toV8StringInternalized(isolate, "endColumn"))
->ToInteger(isolate)
->Value());
m_executionContextAuxData = toProtocolStringWithTypeCheck( m_executionContextAuxData = toProtocolStringWithTypeCheck(
object->Get(toV8StringInternalized(isolate, "executionContextAuxData"))); object->Get(toV8StringInternalized(isolate, "executionContextAuxData")));
m_executionContextId = static_cast<int>( m_executionContextId =
object->Get(toV8StringInternalized(isolate, "executionContextId")) object->Get(toV8StringInternalized(isolate, "executionContextId"))
->ToInteger(isolate) ->ToInteger(isolate)
->Value()); ->Value();
m_isLiveEdit = isLiveEdit; m_isLiveEdit = isLiveEdit;
v8::Local<v8::Value> sourceValue = v8::Local<v8::Value> sourceValue =
......
...@@ -96,8 +96,8 @@ v8::Local<v8::Value> V8FunctionCall::callWithoutExceptionHandling() { ...@@ -96,8 +96,8 @@ v8::Local<v8::Value> V8FunctionCall::callWithoutExceptionHandling() {
} }
v8::MicrotasksScope microtasksScope(m_context->GetIsolate(), v8::MicrotasksScope microtasksScope(m_context->GetIsolate(),
v8::MicrotasksScope::kDoNotRunMicrotasks); v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::MaybeLocal<v8::Value> maybeResult = function->Call( v8::MaybeLocal<v8::Value> maybeResult =
m_context, thisObject, static_cast<int>(m_arguments.size()), info.get()); function->Call(m_context, thisObject, m_arguments.size(), info.get());
if (contextGroupId) { if (contextGroupId) {
m_inspector->client()->unmuteMetrics(contextGroupId); m_inspector->client()->unmuteMetrics(contextGroupId);
m_inspector->unmuteExceptions(contextGroupId); m_inspector->unmuteExceptions(contextGroupId);
......
...@@ -294,7 +294,7 @@ void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString, ...@@ -294,7 +294,7 @@ void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString,
return; return;
v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value); v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value);
*heapSnapshotObjectId = String16::fromInteger(static_cast<size_t>(id)); *heapSnapshotObjectId = String16::fromInteger(id);
} }
void V8HeapProfilerAgentImpl::requestHeapStatsUpdate() { void V8HeapProfilerAgentImpl::requestHeapStatsUpdate() {
......
...@@ -49,7 +49,7 @@ bool markArrayEntriesAsInternal(v8::Local<v8::Context> context, ...@@ -49,7 +49,7 @@ bool markArrayEntriesAsInternal(v8::Local<v8::Context> context,
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Private> privateValue = internalSubtypePrivate(isolate); v8::Local<v8::Private> privateValue = internalSubtypePrivate(isolate);
v8::Local<v8::String> subtype = subtypeForInternalType(isolate, type); v8::Local<v8::String> subtype = subtypeForInternalType(isolate, type);
for (uint32_t i = 0; i < array->Length(); ++i) { for (size_t i = 0; i < array->Length(); ++i) {
v8::Local<v8::Value> entry; v8::Local<v8::Value> entry;
if (!array->Get(context, i).ToLocal(&entry) || !entry->IsObject()) if (!array->Get(context, i).ToLocal(&entry) || !entry->IsObject())
return false; return false;
......
...@@ -364,7 +364,7 @@ void V8RuntimeAgentImpl::callFunctionOn( ...@@ -364,7 +364,7 @@ void V8RuntimeAgentImpl::callFunctionOn(
if (optionalArguments.isJust()) { if (optionalArguments.isJust()) {
protocol::Array<protocol::Runtime::CallArgument>* arguments = protocol::Array<protocol::Runtime::CallArgument>* arguments =
optionalArguments.fromJust(); optionalArguments.fromJust();
argc = static_cast<int>(arguments->length()); argc = arguments->length();
argv.reset(new v8::Local<v8::Value>[argc]); argv.reset(new v8::Local<v8::Value>[argc]);
for (int i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {
v8::Local<v8::Value> argumentValue; v8::Local<v8::Value> argumentValue;
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
#include "include/v8-profiler.h" #include "include/v8-profiler.h"
#include "include/v8-version.h" #include "include/v8-version.h"
#include <limits>
namespace v8_inspector { namespace v8_inspector {
namespace { namespace {
...@@ -47,8 +45,7 @@ void toFramesVector(v8::Local<v8::StackTrace> stackTrace, ...@@ -47,8 +45,7 @@ void toFramesVector(v8::Local<v8::StackTrace> stackTrace,
size_t maxStackSize, v8::Isolate* isolate) { size_t maxStackSize, v8::Isolate* isolate) {
DCHECK(isolate->InContext()); DCHECK(isolate->InContext());
int frameCount = stackTrace->GetFrameCount(); int frameCount = stackTrace->GetFrameCount();
if (frameCount > static_cast<int>(maxStackSize)) if (frameCount > static_cast<int>(maxStackSize)) frameCount = maxStackSize;
frameCount = static_cast<int>(maxStackSize);
for (int i = 0; i < frameCount; i++) { for (int i = 0; i < frameCount; i++) {
v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
frames.push_back(toFrame(stackFrame)); frames.push_back(toFrame(stackFrame));
...@@ -162,9 +159,8 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( ...@@ -162,9 +159,8 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
v8::Local<v8::StackTrace> stackTrace; v8::Local<v8::StackTrace> stackTrace;
if (isolate->InContext()) { if (isolate->InContext()) {
isolate->GetCpuProfiler()->CollectSample(); isolate->GetCpuProfiler()->CollectSample();
DCHECK(maxStackSize <= std::numeric_limits<int>::max()); stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize,
stackTrace = v8::StackTrace::CurrentStackTrace( stackTraceOptions);
isolate, static_cast<int>(maxStackSize), stackTraceOptions);
} }
return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace,
maxStackSize, description); maxStackSize, description);
......
...@@ -30,7 +30,7 @@ class V8ValueCopier { ...@@ -30,7 +30,7 @@ class V8ValueCopier {
v8::Local<v8::Array> result = v8::Array::New(m_isolate, array->Length()); v8::Local<v8::Array> result = v8::Array::New(m_isolate, array->Length());
if (!result->SetPrototype(m_to, v8::Null(m_isolate)).FromMaybe(false)) if (!result->SetPrototype(m_to, v8::Null(m_isolate)).FromMaybe(false))
return v8::MaybeLocal<v8::Value>(); return v8::MaybeLocal<v8::Value>();
for (uint32_t i = 0; i < array->Length(); ++i) { for (size_t i = 0; i < array->Length(); ++i) {
v8::Local<v8::Value> item; v8::Local<v8::Value> item;
if (!array->Get(m_from, i).ToLocal(&item)) if (!array->Get(m_from, i).ToLocal(&item))
return v8::MaybeLocal<v8::Value>(); return v8::MaybeLocal<v8::Value>();
...@@ -49,7 +49,7 @@ class V8ValueCopier { ...@@ -49,7 +49,7 @@ class V8ValueCopier {
v8::Local<v8::Array> properties; v8::Local<v8::Array> properties;
if (!object->GetOwnPropertyNames(m_from).ToLocal(&properties)) if (!object->GetOwnPropertyNames(m_from).ToLocal(&properties))
return v8::MaybeLocal<v8::Value>(); return v8::MaybeLocal<v8::Value>();
for (uint32_t i = 0; i < properties->Length(); ++i) { for (size_t i = 0; i < properties->Length(); ++i) {
v8::Local<v8::Value> name; v8::Local<v8::Value> name;
if (!properties->Get(m_from, i).ToLocal(&name) || !name->IsString()) if (!properties->Get(m_from, i).ToLocal(&name) || !name->IsString())
return v8::MaybeLocal<v8::Value>(); return v8::MaybeLocal<v8::Value>();
......
...@@ -1748,6 +1748,7 @@ ...@@ -1748,6 +1748,7 @@
], ],
# TODO(dgozman): fix these warnings and enable them. # TODO(dgozman): fix these warnings and enable them.
'msvs_disabled_warnings': [ 'msvs_disabled_warnings': [
4267, # Truncation from size_t to int.
4305, # Truncation from 'type1' to 'type2'. 4305, # Truncation from 'type1' to 'type2'.
4324, # Struct padded due to declspec(align). 4324, # Struct padded due to declspec(align).
4714, # Function marked forceinline not inlined. 4714, # Function marked forceinline not inlined.
...@@ -1756,6 +1757,7 @@ ...@@ -1756,6 +1757,7 @@
], ],
'cflags': [ 'cflags': [
'-Wno-zero-length-array', '-Wno-zero-length-array',
'-Wno-shorten-64-to-32',
'-Wno-deprecated-declarations', '-Wno-deprecated-declarations',
], ],
}], }],
......
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