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

Unified Diff: include/v8.h

Issue 16939003: added type checks on fast return values (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index f6e236114e33edca721fe3cb1a37fd216c5af0fb..0f949a8b89f3ca6bcf815447ff45a4ccbe7c2a17 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5712,11 +5712,13 @@ void ReturnValue<T>::Set(const Handle<S> handle) {
template<typename T>
void ReturnValue<T>::Set(double i) {
+ TYPE_CHECK(T, Number);
Set(Number::New(GetIsolate(), i));
}
template<typename T>
void ReturnValue<T>::Set(int32_t i) {
+ TYPE_CHECK(T, Integer);
typedef internal::Internals I;
if (V8_LIKELY(I::IsValidSmi(i))) {
*value_ = I::IntToSmi(i);
@@ -5727,6 +5729,7 @@ void ReturnValue<T>::Set(int32_t i) {
template<typename T>
void ReturnValue<T>::Set(uint32_t i) {
+ TYPE_CHECK(T, Integer);
typedef internal::Internals I;
// Can't simply use INT32_MAX here for whatever reason.
bool fits_into_int32_t = (i & (1 << 31)) == 0;
@@ -5739,6 +5742,7 @@ void ReturnValue<T>::Set(uint32_t i) {
template<typename T>
void ReturnValue<T>::Set(bool value) {
+ TYPE_CHECK(T, Boolean);
typedef internal::Internals I;
int root_index;
if (value) {
@@ -5751,18 +5755,21 @@ void ReturnValue<T>::Set(bool value) {
template<typename T>
void ReturnValue<T>::SetNull() {
+ TYPE_CHECK(T, Primitive);
typedef internal::Internals I;
*value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
}
template<typename T>
void ReturnValue<T>::SetUndefined() {
+ TYPE_CHECK(T, Primitive);
typedef internal::Internals I;
*value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
}
template<typename T>
void ReturnValue<T>::SetEmptyString() {
+ TYPE_CHECK(T, String);
typedef internal::Internals I;
*value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698