Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index bbb9d3e26d1ffe0676d1bc720205d8dd8f6a67c7..bded80b48f0e1a43f1293ba1996423a33541ad15 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -2629,12 +2629,10 @@ MaybeObject* Heap::AllocateForeign(Address address, PretenureFlag pretenure) { |
// Statically ensure that it is safe to allocate foreigns in paged spaces. |
STATIC_ASSERT(Foreign::kSize <= Page::kMaxHeapObjectSize); |
AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
- Object* result; |
- { MaybeObject* maybe_result = Allocate(foreign_map(), space); |
- if (!maybe_result->ToObject(&result)) return maybe_result; |
- } |
- |
- Foreign::cast(result)->set_address(address); |
+ Foreign* result; |
+ MaybeObject* maybe_result = Allocate(foreign_map(), space); |
+ if (!maybe_result->To(&result)) return maybe_result; |
+ result->set_foreign_address(address); |
return result; |
} |