On Sat, Jul 9, 2016 at 12:00 PM, Dmitriy - <dima00...@gmail.com> wrote: > Hello, > > I try to understand what happens in this code: > When you call something you are writing: > __ Call(builtin, RelocInfo::CODE_TARGET); > > What how it looks: > void MacroAssembler::Call(Handle<Code> code_object, > RelocInfo::Mode rmode, > TypeFeedbackId ast_id) { > #ifdef DEBUG > int end_position = pc_offset() + CallSize(code_object); > #endif > DCHECK(RelocInfo::IsCodeTarget(rmode) || > rmode == RelocInfo::CODE_AGE_SEQUENCE); > call(code_object, rmode, ast_id); > #ifdef DEBUG > CHECK_EQ(end_position, pc_offset()); > #endif > } > > Then you go to call(code_object, rmode, ast_id); > > void Assembler::call(Handle<Code> target, > RelocInfo::Mode rmode, > TypeFeedbackId ast_id) { > positions_recorder()->WriteRecordedPositions(); > EnsureSpace ensure_space(this); > // 1110 1000 #32-bit disp. > emit(0xE8); > emit_code_target(target, rmode, ast_id); > } > > Finally: > > void Assembler::emit_code_target(Handle<Code> target, > RelocInfo::Mode rmode, > TypeFeedbackId ast_id) { > DCHECK(RelocInfo::IsCodeTarget(rmode) || > rmode == RelocInfo::CODE_AGE_SEQUENCE); > if (rmode == RelocInfo::CODE_TARGET && !ast_id.IsNone()) { > RecordRelocInfo(RelocInfo::CODE_TARGET_WITH_ID, ast_id.ToInt()); > } else { > RecordRelocInfo(rmode); > } > int current = code_targets_.length(); > if (current > 0 && code_targets_.last().is_identical_to(target)) { > // Optimization if we keep jumping to the same code target. > emitl(current - 1); > } else { > code_targets_.Add(target); > emitl(current); > } > } > > I understand all code besides one things: > int current = code_targets_.length(); > emitl(current); > > We write index of code object in code_targets, why we don't write address to > object directly? > I grep the code and I've not find appropriate using of code_targets. > But with --print_code I can see that v8 generates call by address, not a > index. > > Do you know where v8 translates index from code_targets to appropriate > address?
I think it's Code::CopyFrom() in src/objects.cc, which runs as a fix-up phase in Factory::NewCode() in src/factory.cc. -- -- v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.