Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: src/api.cc

Issue 1477023002: Deprecate Promise::Chain from V8 APIs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Alphabetize includes Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 9078b4d7240fe5bf8059de8dba2bcca23e52a108..eddee479506292be2a7c02c9bc83a69860a9f95b 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -9,6 +9,9 @@
#include <sanitizer/asan_interface.h>
#endif // V8_USE_ADDRESS_SANITIZER
#include <cmath> // For isnan.
+#include <limits>
+#include <string>
+#include <vector>
#include "include/v8-debug.h"
#include "include/v8-profiler.h"
#include "include/v8-testing.h"
@@ -882,8 +885,8 @@ int NeanderArray::length() {
i::Object* NeanderArray::get(int offset) {
- DCHECK(0 <= offset);
- DCHECK(offset < length());
+ DCHECK_LE(0, offset);
+ DCHECK_LT(offset, length());
jochen (gone - plz use gerrit) 2015/12/07 15:39:54 could you please move the unrelated refactoring to
Dan Ehrenberg 2015/12/07 18:57:54 It seems like the lint checking recently got more
return obj_.get(offset + 1);
}
@@ -4833,7 +4836,7 @@ class Utf8LengthHelper : public i::AllStatic {
}
static int Calculate(i::ConsString* current, uint8_t* state_out) {
- using namespace internal;
+ using internal::ConsString;
int total_length = 0;
uint8_t state = kInitialState;
while (true) {
@@ -4933,26 +4936,22 @@ class Utf8WriterVisitor {
int remaining,
char* const buffer,
bool replace_invalid_utf8) {
- using namespace unibrow;
- DCHECK(remaining > 0);
+ DCHECK_GT(remaining, 0);
// We can't use a local buffer here because Encode needs to modify
// previous characters in the stream. We know, however, that
// exactly one character will be advanced.
- if (Utf16::IsSurrogatePair(last_character, character)) {
- int written = Utf8::Encode(buffer,
- character,
- last_character,
- replace_invalid_utf8);
- DCHECK(written == 1);
+ if (unibrow::Utf16::IsSurrogatePair(last_character, character)) {
+ int written = unibrow::Utf8::Encode(buffer, character, last_character,
+ replace_invalid_utf8);
+ DCHECK_EQ(written, 1);
return written;
}
// Use a scratch buffer to check the required characters.
- char temp_buffer[Utf8::kMaxEncodedSize];
+ char temp_buffer[unibrow::Utf8::kMaxEncodedSize];
// Can't encode using last_character as gcc has array bounds issues.
- int written = Utf8::Encode(temp_buffer,
- character,
- Utf16::kNoPreviousCharacter,
- replace_invalid_utf8);
+ int written = unibrow::Utf8::Encode(temp_buffer, character,
+ unibrow::Utf16::kNoPreviousCharacter,
+ replace_invalid_utf8);
// Won't fit.
if (written > remaining) return 0;
// Copy over the character from temp_buffer.
@@ -4974,13 +4973,13 @@ class Utf8WriterVisitor {
// unit, or all units have been written out.
template<typename Char>
void Visit(const Char* chars, const int length) {
- using namespace unibrow;
DCHECK(!early_termination_);
if (length == 0) return;
// Copy state to stack.
char* buffer = buffer_;
- int last_character =
- sizeof(Char) == 1 ? Utf16::kNoPreviousCharacter : last_character_;
+ int last_character = sizeof(Char) == 1
+ ? unibrow::Utf16::kNoPreviousCharacter
+ : last_character_;
int i = 0;
// Do a fast loop where there is no exit capacity check.
while (true) {
@@ -4990,7 +4989,8 @@ class Utf8WriterVisitor {
} else {
int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
// Need enough space to write everything but one character.
- STATIC_ASSERT(Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit == 3);
+ STATIC_ASSERT(unibrow::Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit ==
+ 3);
int max_size_per_char = sizeof(Char) == 1 ? 2 : 3;
int writable_length =
(remaining_capacity - max_size_per_char)/max_size_per_char;
@@ -5002,17 +5002,15 @@ class Utf8WriterVisitor {
// Write the characters to the stream.
if (sizeof(Char) == 1) {
for (; i < fast_length; i++) {
- buffer +=
- Utf8::EncodeOneByte(buffer, static_cast<uint8_t>(*chars++));
+ buffer += unibrow::Utf8::EncodeOneByte(
+ buffer, static_cast<uint8_t>(*chars++));
DCHECK(capacity_ == -1 || (buffer - start_) <= capacity_);
}
} else {
for (; i < fast_length; i++) {
uint16_t character = *chars++;
- buffer += Utf8::Encode(buffer,
- character,
- last_character,
- replace_invalid_utf8_);
+ buffer += unibrow::Utf8::Encode(buffer, character, last_character,
+ replace_invalid_utf8_);
last_character = character;
DCHECK(capacity_ == -1 || (buffer - start_) <= capacity_);
}
@@ -5029,12 +5027,12 @@ class Utf8WriterVisitor {
DCHECK(!skip_capacity_check_);
// Slow loop. Must check capacity on each iteration.
int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
- DCHECK(remaining_capacity >= 0);
+ DCHECK_GE(remaining_capacity, 0);
for (; i < length && remaining_capacity > 0; i++) {
uint16_t character = *chars++;
// remaining_capacity is <= 3 bytes at this point, so we do not write out
// an umatched lead surrogate.
- if (replace_invalid_utf8_ && Utf16::IsLeadSurrogate(character)) {
+ if (replace_invalid_utf8_ && unibrow::Utf16::IsLeadSurrogate(character)) {
early_termination_ = true;
break;
}
@@ -6463,10 +6461,12 @@ void Promise::Resolver::Reject(Local<Value> value) {
}
-MaybeLocal<Promise> Promise::Chain(Local<Context> context,
- Local<Function> handler) {
+namespace {
+
+MaybeLocal<Promise> DoChain(Value* value, Local<Context> context,
+ Local<Function> handler) {
PREPARE_FOR_EXECUTION(context, "Promise::Chain", Promise);
- auto self = Utils::OpenHandle(this);
+ auto self = Utils::OpenHandle(value);
i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)};
i::Handle<i::Object> result;
has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(),
@@ -6476,10 +6476,18 @@ MaybeLocal<Promise> Promise::Chain(Local<Context> context,
RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result)));
}
+} // namespace
+
+
+MaybeLocal<Promise> Promise::Chain(Local<Context> context,
+ Local<Function> handler) {
+ return DoChain(this, context, handler);
+}
+
Local<Promise> Promise::Chain(Local<Function> handler) {
auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- RETURN_TO_LOCAL_UNCHECKED(Chain(context, handler), Promise);
+ RETURN_TO_LOCAL_UNCHECKED(DoChain(this, context, handler), Promise);
}
@@ -8032,7 +8040,7 @@ int CpuProfile::GetSamplesCount() const {
void CpuProfiler::SetSamplingInterval(int us) {
- DCHECK(us >= 0);
+ DCHECK_GE(us, 0);
return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval(
base::TimeDelta::FromMicroseconds(us));
}
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698