Commit 1f82fb54 authored by jgruber's avatar jgruber Committed by Commit Bot

[builtins] Fix Code::contains for off-heap trampolines

Code::contains should return true in two cases: either the given
address is within the off-heap instruction stream, or within the
trampoline's instruction stream.

This CL fixes the second case. One effect is that code printed through
the jco gdb macro again displays the builtin name correctly when given
a trampoline pc.

Drive-by: a more efficient Builtins::Lookup for embedded builtins.

Bug: v8:6666,v8:7969
Change-Id: I54f5e5881fa2aed2546b9e62aa4b9390ad21b895
Reviewed-on: https://chromium-review.googlesource.com/1146566Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54605}
parent 64e3912f
......@@ -7,6 +7,7 @@
#include "src/assembler-inl.h"
#include "src/builtins/builtins-descriptors.h"
#include "src/callable.h"
#include "src/instruction-stream.h"
#include "src/isolate.h"
#include "src/macro-assembler.h"
#include "src/objects-inl.h"
......@@ -80,7 +81,13 @@ Builtins::Name Builtins::GetBuiltinFromBailoutId(BailoutId id) {
void Builtins::TearDown() { initialized_ = false; }
const char* Builtins::Lookup(Address pc) {
// may be called during initialization (disassembler!)
// Off-heap pc's can be looked up through binary search.
if (FLAG_embedded_builtins) {
Code* maybe_builtin = InstructionStream::TryLookupCode(isolate_, pc);
if (maybe_builtin != nullptr) return name(maybe_builtin->builtin_index());
}
// May be called during initialization (disassembler).
if (initialized_) {
for (int i = 0; i < builtin_count; i++) {
if (isolate_->heap()->builtin(i)->contains(pc)) return name(i);
......
......@@ -314,8 +314,10 @@ Address Code::entry() const { return raw_instruction_start(); }
bool Code::contains(Address inner_pointer) {
if (is_off_heap_trampoline()) {
DCHECK(FLAG_embedded_builtins);
return (OffHeapInstructionStart() <= inner_pointer) &&
(inner_pointer < OffHeapInstructionEnd());
if (OffHeapInstructionStart() <= inner_pointer &&
inner_pointer < OffHeapInstructionEnd()) {
return true;
}
}
return (address() <= inner_pointer) && (inner_pointer < address() + 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