Commit 99d9abaf authored by dcarney@chromium.org's avatar dcarney@chromium.org

remove this == null

R=danno@chromium.org

BUG=chromium:381910

Review URL: https://codereview.chromium.org/336483002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21807 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4d4485e4
...@@ -1192,14 +1192,14 @@ static i::Handle<i::AccessorInfo> MakeAccessorInfo( ...@@ -1192,14 +1192,14 @@ static i::Handle<i::AccessorInfo> MakeAccessorInfo(
Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this, true);
if (!Utils::ApiCheck(this != NULL, if (!Utils::ApiCheck(!handle.is_null(),
"v8::FunctionTemplate::InstanceTemplate()", "v8::FunctionTemplate::InstanceTemplate()",
"Reading from empty handle")) { "Reading from empty handle")) {
return Local<ObjectTemplate>(); return Local<ObjectTemplate>();
} }
i::Isolate* isolate = handle->GetIsolate();
ENTER_V8(isolate); ENTER_V8(isolate);
i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this);
if (handle->instance_template()->IsUndefined()) { if (handle->instance_template()->IsUndefined()) {
Local<ObjectTemplate> templ = Local<ObjectTemplate> templ =
ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle)); ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle));
...@@ -1616,11 +1616,11 @@ Handle<Value> UnboundScript::GetScriptName() { ...@@ -1616,11 +1616,11 @@ Handle<Value> UnboundScript::GetScriptName() {
Local<Value> Script::Run() { Local<Value> Script::Run() {
i::Handle<i::HeapObject> obj =
i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this, true));
// If execution is terminating, Compile(..)->Run() requires this // If execution is terminating, Compile(..)->Run() requires this
// check. // check.
if (this == NULL) return Local<Value>(); if (obj.is_null()) return Local<Value>();
i::Handle<i::HeapObject> obj =
i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
i::Isolate* isolate = obj->GetIsolate(); i::Isolate* isolate = obj->GetIsolate();
ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
LOG_API(isolate, "Script::Run"); LOG_API(isolate, "Script::Run");
...@@ -2912,14 +2912,14 @@ int32_t Value::Int32Value() const { ...@@ -2912,14 +2912,14 @@ int32_t Value::Int32Value() const {
bool Value::Equals(Handle<Value> that) const { bool Value::Equals(Handle<Value> that) const {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(), i::Handle<i::Object> obj = Utils::OpenHandle(this, true);
if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(),
"v8::Value::Equals()", "v8::Value::Equals()",
"Reading from empty handle")) { "Reading from empty handle")) {
return false; return false;
} }
LOG_API(isolate, "Equals"); LOG_API(isolate, "Equals");
ENTER_V8(isolate); ENTER_V8(isolate);
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> other = Utils::OpenHandle(*that); i::Handle<i::Object> other = Utils::OpenHandle(*that);
// If both obj and other are JSObjects, we'd better compare by identity // If both obj and other are JSObjects, we'd better compare by identity
// immediately when going into JS builtin. The reason is Invoke // immediately when going into JS builtin. The reason is Invoke
...@@ -2939,13 +2939,13 @@ bool Value::Equals(Handle<Value> that) const { ...@@ -2939,13 +2939,13 @@ bool Value::Equals(Handle<Value> that) const {
bool Value::StrictEquals(Handle<Value> that) const { bool Value::StrictEquals(Handle<Value> that) const {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(), i::Handle<i::Object> obj = Utils::OpenHandle(this, true);
if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(),
"v8::Value::StrictEquals()", "v8::Value::StrictEquals()",
"Reading from empty handle")) { "Reading from empty handle")) {
return false; return false;
} }
LOG_API(isolate, "StrictEquals"); LOG_API(isolate, "StrictEquals");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> other = Utils::OpenHandle(*that); i::Handle<i::Object> other = Utils::OpenHandle(*that);
// Must check HeapNumber first, since NaN !== NaN. // Must check HeapNumber first, since NaN !== NaN.
if (obj->IsHeapNumber()) { if (obj->IsHeapNumber()) {
...@@ -2971,12 +2971,12 @@ bool Value::StrictEquals(Handle<Value> that) const { ...@@ -2971,12 +2971,12 @@ bool Value::StrictEquals(Handle<Value> that) const {
bool Value::SameValue(Handle<Value> that) const { bool Value::SameValue(Handle<Value> that) const {
if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(), i::Handle<i::Object> obj = Utils::OpenHandle(this, true);
if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(),
"v8::Value::SameValue()", "v8::Value::SameValue()",
"Reading from empty handle")) { "Reading from empty handle")) {
return false; return false;
} }
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> other = Utils::OpenHandle(*that); i::Handle<i::Object> other = Utils::OpenHandle(*that);
return obj->SameValue(*other); return obj->SameValue(*other);
} }
......
...@@ -1411,7 +1411,8 @@ Handle<Code> Factory::NewCode(const CodeDesc& desc, ...@@ -1411,7 +1411,8 @@ Handle<Code> Factory::NewCode(const CodeDesc& desc,
int obj_size = Code::SizeFor(body_size); int obj_size = Code::SizeFor(body_size);
Handle<Code> code = NewCodeRaw(obj_size, immovable); Handle<Code> code = NewCodeRaw(obj_size, immovable);
ASSERT(!isolate()->code_range()->exists() || ASSERT(isolate()->code_range() == NULL ||
!isolate()->code_range()->valid() ||
isolate()->code_range()->contains(code->address())); isolate()->code_range()->contains(code->address()));
// The code object has not been fully initialized yet. We rely on the // The code object has not been fully initialized yet. We rely on the
......
...@@ -3365,8 +3365,9 @@ AllocationResult Heap::AllocateCode(int object_size, ...@@ -3365,8 +3365,9 @@ AllocationResult Heap::AllocateCode(int object_size,
result->set_map_no_write_barrier(code_map()); result->set_map_no_write_barrier(code_map());
Code* code = Code::cast(result); Code* code = Code::cast(result);
ASSERT(!isolate_->code_range()->exists() || ASSERT(isolate_->code_range() == NULL ||
isolate_->code_range()->contains(code->address())); !isolate_->code_range()->valid() ||
isolate_->code_range()->contains(code->address()));
code->set_gc_metadata(Smi::FromInt(0)); code->set_gc_metadata(Smi::FromInt(0));
code->set_ic_age(global_ic_age_); code->set_ic_age(global_ic_age_);
return code; return code;
...@@ -3407,8 +3408,9 @@ AllocationResult Heap::CopyCode(Code* code) { ...@@ -3407,8 +3408,9 @@ AllocationResult Heap::CopyCode(Code* code) {
new_code->set_constant_pool(new_constant_pool); new_code->set_constant_pool(new_constant_pool);
// Relocate the copy. // Relocate the copy.
ASSERT(!isolate_->code_range()->exists() || ASSERT(isolate_->code_range() == NULL ||
isolate_->code_range()->contains(code->address())); !isolate_->code_range()->valid() ||
isolate_->code_range()->contains(code->address()));
new_code->Relocate(new_addr - old_addr); new_code->Relocate(new_addr - old_addr);
return new_code; return new_code;
} }
...@@ -3471,8 +3473,9 @@ AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) { ...@@ -3471,8 +3473,9 @@ AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
static_cast<size_t>(reloc_info.length())); static_cast<size_t>(reloc_info.length()));
// Relocate the copy. // Relocate the copy.
ASSERT(!isolate_->code_range()->exists() || ASSERT(isolate_->code_range() == NULL ||
isolate_->code_range()->contains(code->address())); !isolate_->code_range()->valid() ||
isolate_->code_range()->contains(code->address()));
new_code->Relocate(new_addr - old_addr); new_code->Relocate(new_addr - old_addr);
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
......
...@@ -25,11 +25,10 @@ class HFieldApproximation : public ZoneObject { ...@@ -25,11 +25,10 @@ class HFieldApproximation : public ZoneObject {
// Recursively copy the entire linked list of field approximations. // Recursively copy the entire linked list of field approximations.
HFieldApproximation* Copy(Zone* zone) { HFieldApproximation* Copy(Zone* zone) {
if (this == NULL) return NULL;
HFieldApproximation* copy = new(zone) HFieldApproximation(); HFieldApproximation* copy = new(zone) HFieldApproximation();
copy->object_ = this->object_; copy->object_ = this->object_;
copy->last_value_ = this->last_value_; copy->last_value_ = this->last_value_;
copy->next_ = this->next_->Copy(zone); copy->next_ = this->next_ == NULL ? NULL : this->next_->Copy(zone);
return copy; return copy;
} }
}; };
...@@ -148,7 +147,7 @@ class HLoadEliminationTable : public ZoneObject { ...@@ -148,7 +147,7 @@ class HLoadEliminationTable : public ZoneObject {
new(zone) HLoadEliminationTable(zone, aliasing_); new(zone) HLoadEliminationTable(zone, aliasing_);
copy->EnsureFields(fields_.length()); copy->EnsureFields(fields_.length());
for (int i = 0; i < fields_.length(); i++) { for (int i = 0; i < fields_.length(); i++) {
copy->fields_[i] = fields_[i]->Copy(zone); copy->fields_[i] = fields_[i] == NULL ? NULL : fields_[i]->Copy(zone);
} }
if (FLAG_trace_load_elimination) { if (FLAG_trace_load_elimination) {
TRACE((" copy-to B%d\n", succ->block_id())); TRACE((" copy-to B%d\n", succ->block_id()));
......
...@@ -322,9 +322,12 @@ void MemoryAllocator::FreeMemory(VirtualMemory* reservation, ...@@ -322,9 +322,12 @@ void MemoryAllocator::FreeMemory(VirtualMemory* reservation,
size_executable_ -= size; size_executable_ -= size;
} }
// Code which is part of the code-range does not have its own VirtualMemory. // Code which is part of the code-range does not have its own VirtualMemory.
ASSERT(!isolate_->code_range()->contains( ASSERT(isolate_->code_range() == NULL ||
static_cast<Address>(reservation->address()))); !isolate_->code_range()->contains(
ASSERT(executable == NOT_EXECUTABLE || !isolate_->code_range()->exists()); static_cast<Address>(reservation->address())));
ASSERT(executable == NOT_EXECUTABLE ||
isolate_->code_range() == NULL ||
!isolate_->code_range()->valid());
reservation->Release(); reservation->Release();
} }
...@@ -342,11 +345,14 @@ void MemoryAllocator::FreeMemory(Address base, ...@@ -342,11 +345,14 @@ void MemoryAllocator::FreeMemory(Address base,
ASSERT(size_executable_ >= size); ASSERT(size_executable_ >= size);
size_executable_ -= size; size_executable_ -= size;
} }
if (isolate_->code_range()->contains(static_cast<Address>(base))) { if (isolate_->code_range() != NULL &&
isolate_->code_range()->contains(static_cast<Address>(base))) {
ASSERT(executable == EXECUTABLE); ASSERT(executable == EXECUTABLE);
isolate_->code_range()->FreeRawMemory(base, size); isolate_->code_range()->FreeRawMemory(base, size);
} else { } else {
ASSERT(executable == NOT_EXECUTABLE || !isolate_->code_range()->exists()); ASSERT(executable == NOT_EXECUTABLE ||
isolate_->code_range() == NULL ||
!isolate_->code_range()->valid());
bool result = VirtualMemory::ReleaseRegion(base, size); bool result = VirtualMemory::ReleaseRegion(base, size);
USE(result); USE(result);
ASSERT(result); ASSERT(result);
...@@ -522,7 +528,8 @@ bool MemoryChunk::CommitArea(size_t requested) { ...@@ -522,7 +528,8 @@ bool MemoryChunk::CommitArea(size_t requested) {
} }
} else { } else {
CodeRange* code_range = heap_->isolate()->code_range(); CodeRange* code_range = heap_->isolate()->code_range();
ASSERT(code_range->exists() && IsFlagSet(IS_EXECUTABLE)); ASSERT(code_range != NULL && code_range->valid() &&
IsFlagSet(IS_EXECUTABLE));
if (!code_range->CommitRawMemory(start, length)) return false; if (!code_range->CommitRawMemory(start, length)) return false;
} }
...@@ -538,7 +545,8 @@ bool MemoryChunk::CommitArea(size_t requested) { ...@@ -538,7 +545,8 @@ bool MemoryChunk::CommitArea(size_t requested) {
if (!reservation_.Uncommit(start, length)) return false; if (!reservation_.Uncommit(start, length)) return false;
} else { } else {
CodeRange* code_range = heap_->isolate()->code_range(); CodeRange* code_range = heap_->isolate()->code_range();
ASSERT(code_range->exists() && IsFlagSet(IS_EXECUTABLE)); ASSERT(code_range != NULL && code_range->valid() &&
IsFlagSet(IS_EXECUTABLE));
if (!code_range->UncommitRawMemory(start, length)) return false; if (!code_range->UncommitRawMemory(start, length)) return false;
} }
} }
...@@ -628,7 +636,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size, ...@@ -628,7 +636,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size,
OS::CommitPageSize()); OS::CommitPageSize());
// Allocate executable memory either from code range or from the // Allocate executable memory either from code range or from the
// OS. // OS.
if (isolate_->code_range()->exists()) { if (isolate_->code_range() != NULL && isolate_->code_range()->valid()) {
base = isolate_->code_range()->AllocateRawMemory(chunk_size, base = isolate_->code_range()->AllocateRawMemory(chunk_size,
commit_size, commit_size,
&chunk_size); &chunk_size);
...@@ -1050,8 +1058,9 @@ intptr_t PagedSpace::SizeOfFirstPage() { ...@@ -1050,8 +1058,9 @@ intptr_t PagedSpace::SizeOfFirstPage() {
case PROPERTY_CELL_SPACE: case PROPERTY_CELL_SPACE:
size = 8 * kPointerSize * KB; size = 8 * kPointerSize * KB;
break; break;
case CODE_SPACE: case CODE_SPACE: {
if (heap()->isolate()->code_range()->exists()) { CodeRange* code_range = heap()->isolate()->code_range();
if (code_range != NULL && code_range->valid()) {
// When code range exists, code pages are allocated in a special way // When code range exists, code pages are allocated in a special way
// (from the reserved code range). That part of the code is not yet // (from the reserved code range). That part of the code is not yet
// upgraded to handle small pages. // upgraded to handle small pages.
...@@ -1062,6 +1071,7 @@ intptr_t PagedSpace::SizeOfFirstPage() { ...@@ -1062,6 +1071,7 @@ intptr_t PagedSpace::SizeOfFirstPage() {
kPointerSize); kPointerSize);
} }
break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
} }
......
...@@ -929,13 +929,13 @@ class CodeRange { ...@@ -929,13 +929,13 @@ class CodeRange {
// manage it. // manage it.
void TearDown(); void TearDown();
bool exists() { return this != NULL && code_range_ != NULL; } bool valid() { return code_range_ != NULL; }
Address start() { Address start() {
if (this == NULL || code_range_ == NULL) return NULL; ASSERT(valid());
return static_cast<Address>(code_range_->address()); return static_cast<Address>(code_range_->address());
} }
bool contains(Address address) { bool contains(Address address) {
if (this == NULL || code_range_ == NULL) return false; if (!valid()) return false;
Address start = static_cast<Address>(code_range_->address()); Address start = static_cast<Address>(code_range_->address());
return start <= address && address < start + code_range_->size(); return start <= address && address < start + code_range_->size();
} }
......
...@@ -77,7 +77,6 @@ void Assembler::emit_code_target(Handle<Code> target, ...@@ -77,7 +77,6 @@ void Assembler::emit_code_target(Handle<Code> target,
void Assembler::emit_runtime_entry(Address entry, RelocInfo::Mode rmode) { void Assembler::emit_runtime_entry(Address entry, RelocInfo::Mode rmode) {
ASSERT(RelocInfo::IsRuntimeEntry(rmode)); ASSERT(RelocInfo::IsRuntimeEntry(rmode));
ASSERT(isolate()->code_range()->exists());
RecordRelocInfo(rmode); RecordRelocInfo(rmode);
emitl(static_cast<uint32_t>(entry - isolate()->code_range()->start())); emitl(static_cast<uint32_t>(entry - isolate()->code_range()->start()));
} }
...@@ -213,7 +212,6 @@ Handle<Object> Assembler::code_target_object_handle_at(Address pc) { ...@@ -213,7 +212,6 @@ Handle<Object> Assembler::code_target_object_handle_at(Address pc) {
Address Assembler::runtime_entry_at(Address pc) { Address Assembler::runtime_entry_at(Address pc) {
ASSERT(isolate()->code_range()->exists());
return Memory::int32_at(pc) + isolate()->code_range()->start(); return Memory::int32_at(pc) + isolate()->code_range()->start();
} }
......
...@@ -169,7 +169,7 @@ static void VerifyMemoryChunk(Isolate* isolate, ...@@ -169,7 +169,7 @@ static void VerifyMemoryChunk(Isolate* isolate,
commit_area_size, commit_area_size,
executable, executable,
NULL); NULL);
size_t alignment = code_range->exists() ? size_t alignment = code_range != NULL && code_range->valid() ?
MemoryChunk::kAlignment : OS::CommitPageSize(); MemoryChunk::kAlignment : OS::CommitPageSize();
size_t reserved_size = ((executable == EXECUTABLE)) size_t reserved_size = ((executable == EXECUTABLE))
? RoundUp(header_size + guard_size + reserve_area_size + guard_size, ? RoundUp(header_size + guard_size + reserve_area_size + guard_size,
......
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