HandleScope scope;
ASSERT(boilerplate->IsBoilerplate());
Handle<CompilationCacheTable> table = GetTable(0);
- // TODO(X64): -fstrict-aliasing causes a problem with table. Fix it.
CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate));
}
template<class T>
Handle<T>::Handle(T* obj) {
ASSERT(!obj->IsFailure());
- location_ = reinterpret_cast<T**>(HandleScope::CreateHandle(obj));
+ location_ = HandleScope::CreateHandle(obj);
}
}
static Handle<T> null() { return Handle<T>(); }
- bool is_null() {return location_ == NULL; }
+ bool is_null() { return location_ == NULL; }
// Closes the given scope, but lets this handle escape. See
// implementation in api.h.
static int NumberOfHandles();
// Creates a new handle with the given value.
- static inline Object** CreateHandle(Object* value) {
- void** result = current_.next;
- if (result == current_.limit) result = Extend();
+ template <typename T>
+ static inline T** CreateHandle(T* value) {
+ void** cur = current_.next;
+ if (cur == current_.limit) cur = Extend();
// Update the current next field, set the value in the created
// handle, and return the result.
- ASSERT(result < current_.limit);
- current_.next = result + 1;
- *reinterpret_cast<Object**>(result) = value;
- return reinterpret_cast<Object**>(result);
+ ASSERT(cur < current_.limit);
+ current_.next = cur + 1;
+
+ T** result = reinterpret_cast<T**>(cur);
+ *result = value;
+ return result;
}
private: