31
31
32
32
#include " bootstrapper.h"
33
33
#include " compiler.h"
34
+ #include " frames.h"
35
+ #include " frames-inl.h"
34
36
#include " global-handles.h"
35
37
#include " messages.h"
36
- #include " platform.h"
37
38
#include " natives.h"
38
- #include " scopeinfo.h"
39
+ #include " platform.h"
40
+ #include " scopes.h"
39
41
40
42
namespace v8 {
41
43
namespace internal {
@@ -194,7 +196,7 @@ class DebugSectionBase : public ZoneObject {
194
196
195
197
virtual void WriteBody (Writer::Slot<THeader> header, Writer* writer) {
196
198
uintptr_t start = writer->position ();
197
- if (WriteBody (writer)) {
199
+ if (WriteBodyInternal (writer)) {
198
200
uintptr_t end = writer->position ();
199
201
header->offset = start;
200
202
#if defined(__MACH_O)
@@ -204,7 +206,7 @@ class DebugSectionBase : public ZoneObject {
204
206
}
205
207
}
206
208
207
- virtual bool WriteBody (Writer* writer) {
209
+ virtual bool WriteBodyInternal (Writer* writer) {
208
210
return false ;
209
211
}
210
212
@@ -340,14 +342,14 @@ class ELFSection : public DebugSectionBase<ELFSectionHeader> {
340
342
341
343
virtual void WriteBody (Writer::Slot<Header> header, Writer* w) {
342
344
uintptr_t start = w->position ();
343
- if (WriteBody (w)) {
345
+ if (WriteBodyInternal (w)) {
344
346
uintptr_t end = w->position ();
345
347
header->offset = start;
346
348
header->size = end - start;
347
349
}
348
350
}
349
351
350
- virtual bool WriteBody (Writer* w) {
352
+ virtual bool WriteBodyInternal (Writer* w) {
351
353
return false ;
352
354
}
353
355
@@ -627,9 +629,9 @@ class MachO BASE_EMBEDDED {
627
629
#if defined(__ELF)
628
630
class ELF BASE_EMBEDDED {
629
631
public:
630
- ELF () : sections_(6 ) {
631
- sections_.Add (new ELFSection (" " , ELFSection::TYPE_NULL, 0 ));
632
- sections_.Add (new StringTable (" .shstrtab" ));
632
+ ELF (Zone* zone ) : sections_(6 , zone ) {
633
+ sections_.Add (new (zone) ELFSection (" " , ELFSection::TYPE_NULL, 0 ), zone );
634
+ sections_.Add (new (zone) StringTable (" .shstrtab" ), zone );
633
635
}
634
636
635
637
void Write (Writer* w) {
@@ -642,8 +644,8 @@ class ELF BASE_EMBEDDED {
642
644
return sections_[index ];
643
645
}
644
646
645
- uint32_t AddSection (ELFSection* section) {
646
- sections_.Add (section);
647
+ uint32_t AddSection (ELFSection* section, Zone* zone ) {
648
+ sections_.Add (section, zone );
647
649
section->set_index (sections_.length () - 1 );
648
650
return sections_.length () - 1 ;
649
651
}
@@ -675,7 +677,7 @@ class ELF BASE_EMBEDDED {
675
677
{ 0x7f , ' E' , ' L' , ' F' , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
676
678
#elif defined(V8_TARGET_ARCH_X64)
677
679
const uint8_t ident[16 ] =
678
- { 0x7f , ' E' , ' L' , ' F' , 2 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
680
+ { 0x7f , ' E' , ' L' , ' F' , 2 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
679
681
#else
680
682
#error Unsupported target architecture.
681
683
#endif
@@ -852,10 +854,10 @@ class ELFSymbol BASE_EMBEDDED {
852
854
853
855
class ELFSymbolTable : public ELFSection {
854
856
public:
855
- explicit ELFSymbolTable (const char * name)
857
+ ELFSymbolTable (const char * name, Zone* zone )
856
858
: ELFSection(name, TYPE_SYMTAB, sizeof (uintptr_t )),
857
- locals_(1 ),
858
- globals_(1 ) {
859
+ locals_ (1 , zone ),
860
+ globals_(1 , zone ) {
859
861
}
860
862
861
863
virtual void WriteBody (Writer::Slot<Header> header, Writer* w) {
@@ -883,11 +885,11 @@ class ELFSymbolTable : public ELFSection {
883
885
strtab->DetachWriter ();
884
886
}
885
887
886
- void Add (const ELFSymbol& symbol) {
888
+ void Add (const ELFSymbol& symbol, Zone* zone ) {
887
889
if (symbol.binding () == ELFSymbol::BIND_LOCAL) {
888
- locals_.Add (symbol);
890
+ locals_.Add (symbol, zone );
889
891
} else {
890
- globals_.Add (symbol);
892
+ globals_.Add (symbol, zone );
891
893
}
892
894
}
893
895
@@ -1019,26 +1021,29 @@ class CodeDescription BASE_EMBEDDED {
1019
1021
static void CreateSymbolsTable (CodeDescription* desc,
1020
1022
ELF* elf,
1021
1023
int text_section_index) {
1022
- ELFSymbolTable* symtab = new ELFSymbolTable (" .symtab" );
1023
- StringTable* strtab = new StringTable (" .strtab" );
1024
+ Zone* zone = desc->info ()->zone ();
1025
+ ELFSymbolTable* symtab = new (zone) ELFSymbolTable (" .symtab" , zone);
1026
+ StringTable* strtab = new (zone) StringTable (" .strtab" );
1024
1027
1025
1028
// Symbol table should be followed by the linked string table.
1026
- elf->AddSection (symtab);
1027
- elf->AddSection (strtab);
1029
+ elf->AddSection (symtab, zone );
1030
+ elf->AddSection (strtab, zone );
1028
1031
1029
1032
symtab->Add (ELFSymbol (" V8 Code" ,
1030
1033
0 ,
1031
1034
0 ,
1032
1035
ELFSymbol::BIND_LOCAL,
1033
1036
ELFSymbol::TYPE_FILE,
1034
- ELFSection::INDEX_ABSOLUTE));
1037
+ ELFSection::INDEX_ABSOLUTE),
1038
+ zone);
1035
1039
1036
1040
symtab->Add (ELFSymbol (desc->name (),
1037
1041
0 ,
1038
1042
desc->CodeSize (),
1039
1043
ELFSymbol::BIND_GLOBAL,
1040
1044
ELFSymbol::TYPE_FUNC,
1041
- text_section_index));
1045
+ text_section_index),
1046
+ zone);
1042
1047
}
1043
1048
#endif // defined(__ELF)
1044
1049
@@ -1074,7 +1079,7 @@ class DebugInfoSection : public DebugSection {
1074
1079
DW_ATE_SIGNED = 0x5
1075
1080
};
1076
1081
1077
- bool WriteBody (Writer* w) {
1082
+ bool WriteBodyInternal (Writer* w) {
1078
1083
uintptr_t cu_start = w->position ();
1079
1084
Writer::Slot<uint32_t > size = w->CreateSlotHere <uint32_t >();
1080
1085
uintptr_t start = w->position ();
@@ -1094,8 +1099,7 @@ class DebugInfoSection : public DebugSection {
1094
1099
w->WriteString (" v8value" );
1095
1100
1096
1101
if (desc_->IsInfoAvailable ()) {
1097
- CompilationInfo* info = desc_->info ();
1098
- ScopeInfo<FreeStoreAllocationPolicy> scope_info (info->scope ());
1102
+ Scope* scope = desc_->info ()->scope ();
1099
1103
w->WriteULEB128 (2 );
1100
1104
w->WriteString (desc_->name ());
1101
1105
w->Write <intptr_t >(desc_->CodeStart ());
@@ -1106,23 +1110,27 @@ class DebugInfoSection : public DebugSection {
1106
1110
w->Write <uint8_t >(DW_OP_reg5); // The frame pointer's here on ia32
1107
1111
#elif defined(V8_TARGET_ARCH_X64)
1108
1112
w->Write <uint8_t >(DW_OP_reg6); // and here on x64.
1113
+ #elif defined(V8_TARGET_ARCH_ARM)
1114
+ UNIMPLEMENTED ();
1115
+ #elif defined(V8_TARGET_ARCH_MIPS)
1116
+ UNIMPLEMENTED ();
1109
1117
#else
1110
1118
#error Unsupported target architecture.
1111
1119
#endif
1112
1120
fb_block_size.set (static_cast <uint32_t >(w->position () - fb_block_start));
1113
1121
1114
- int params = scope_info. number_of_parameters ();
1115
- int slots = scope_info. number_of_stack_slots ();
1116
- int context_slots = scope_info. number_of_context_slots ();
1122
+ int params = scope-> num_parameters ();
1123
+ int slots = scope-> num_stack_slots ();
1124
+ int context_slots = scope-> ContextLocalCount ();
1117
1125
// The real slot ID is internal_slots + context_slot_id.
1118
1126
int internal_slots = Context::MIN_CONTEXT_SLOTS;
1119
- int locals = scope_info. LocalCount ();
1127
+ int locals = scope-> StackLocalCount ();
1120
1128
int current_abbreviation = 4 ;
1121
1129
1122
1130
for (int param = 0 ; param < params; ++param) {
1123
1131
w->WriteULEB128 (current_abbreviation++);
1124
1132
w->WriteString (
1125
- *scope_info. ParameterName (param)->ToCString (DISALLOW_NULLS));
1133
+ *scope-> parameter (param)-> name ( )->ToCString (DISALLOW_NULLS));
1126
1134
w->Write <uint32_t >(ty_offset);
1127
1135
Writer::Slot<uint32_t > block_size = w->CreateSlotHere <uint32_t >();
1128
1136
uintptr_t block_start = w->position ();
@@ -1148,7 +1156,7 @@ class DebugInfoSection : public DebugSection {
1148
1156
ASSERT (Context::CLOSURE_INDEX == 0 );
1149
1157
ASSERT (Context::PREVIOUS_INDEX == 1 );
1150
1158
ASSERT (Context::EXTENSION_INDEX == 2 );
1151
- ASSERT (Context::GLOBAL_INDEX == 3 );
1159
+ ASSERT (Context::GLOBAL_OBJECT_INDEX == 3 );
1152
1160
w->WriteULEB128 (current_abbreviation++);
1153
1161
w->WriteString (" .closure" );
1154
1162
w->WriteULEB128 (current_abbreviation++);
@@ -1167,10 +1175,13 @@ class DebugInfoSection : public DebugSection {
1167
1175
w->WriteString (builder.Finalize ());
1168
1176
}
1169
1177
1178
+ ZoneList<Variable*> stack_locals (locals, scope->zone ());
1179
+ ZoneList<Variable*> context_locals (context_slots, scope->zone ());
1180
+ scope->CollectStackAndContextLocals (&stack_locals, &context_locals);
1170
1181
for (int local = 0 ; local < locals; ++local) {
1171
1182
w->WriteULEB128 (current_abbreviation++);
1172
1183
w->WriteString (
1173
- *scope_info. LocalName ( local)->ToCString (DISALLOW_NULLS));
1184
+ *stack_locals[ local]-> name ( )->ToCString (DISALLOW_NULLS));
1174
1185
w->Write <uint32_t >(ty_offset);
1175
1186
Writer::Slot<uint32_t > block_size = w->CreateSlotHere <uint32_t >();
1176
1187
uintptr_t block_start = w->position ();
@@ -1287,7 +1298,7 @@ class DebugAbbrevSection : public DebugSection {
1287
1298
w->WriteULEB128 (0 );
1288
1299
}
1289
1300
1290
- bool WriteBody (Writer* w) {
1301
+ bool WriteBodyInternal (Writer* w) {
1291
1302
int current_abbreviation = 1 ;
1292
1303
bool extra_info = desc_->IsInfoAvailable ();
1293
1304
ASSERT (desc_->IsLineInfoAvailable ());
@@ -1306,14 +1317,13 @@ class DebugAbbrevSection : public DebugSection {
1306
1317
w->WriteULEB128 (0 );
1307
1318
1308
1319
if (extra_info) {
1309
- CompilationInfo* info = desc_->info ();
1310
- ScopeInfo<FreeStoreAllocationPolicy> scope_info (info->scope ());
1311
- int params = scope_info.number_of_parameters ();
1312
- int slots = scope_info.number_of_stack_slots ();
1313
- int context_slots = scope_info.number_of_context_slots ();
1320
+ Scope* scope = desc_->info ()->scope ();
1321
+ int params = scope->num_parameters ();
1322
+ int slots = scope->num_stack_slots ();
1323
+ int context_slots = scope->ContextLocalCount ();
1314
1324
// The real slot ID is internal_slots + context_slot_id.
1315
1325
int internal_slots = Context::MIN_CONTEXT_SLOTS;
1316
- int locals = scope_info. LocalCount ();
1326
+ int locals = scope-> StackLocalCount ();
1317
1327
int total_children =
1318
1328
params + slots + context_slots + internal_slots + locals + 2 ;
1319
1329
@@ -1418,7 +1428,7 @@ class DebugLineSection : public DebugSection {
1418
1428
DW_LNE_DEFINE_FILE = 3
1419
1429
};
1420
1430
1421
- bool WriteBody (Writer* w) {
1431
+ bool WriteBodyInternal (Writer* w) {
1422
1432
// Write prologue.
1423
1433
Writer::Slot<uint32_t > total_length = w->CreateSlotHere <uint32_t >();
1424
1434
uintptr_t start = w->position ();
@@ -1558,7 +1568,7 @@ class DebugLineSection : public DebugSection {
1558
1568
class UnwindInfoSection : public DebugSection {
1559
1569
public:
1560
1570
explicit UnwindInfoSection (CodeDescription* desc);
1561
- virtual bool WriteBody (Writer* w);
1571
+ virtual bool WriteBodyInternal (Writer* w);
1562
1572
1563
1573
int WriteCIE (Writer* w);
1564
1574
void WriteFDE (Writer* w, int );
@@ -1770,7 +1780,7 @@ void UnwindInfoSection::WriteFDEStateAfterRBPPop(Writer* w) {
1770
1780
}
1771
1781
1772
1782
1773
- bool UnwindInfoSection::WriteBody (Writer* w) {
1783
+ bool UnwindInfoSection::WriteBodyInternal (Writer* w) {
1774
1784
uint32_t cie_position = WriteCIE (w);
1775
1785
WriteFDE (w, cie_position);
1776
1786
return true ;
@@ -1780,13 +1790,14 @@ bool UnwindInfoSection::WriteBody(Writer* w) {
1780
1790
#endif // V8_TARGET_ARCH_X64
1781
1791
1782
1792
static void CreateDWARFSections (CodeDescription* desc, DebugObject* obj) {
1793
+ Zone* zone = desc->info ()->zone ();
1783
1794
if (desc->IsLineInfoAvailable ()) {
1784
- obj->AddSection (new DebugInfoSection (desc));
1785
- obj->AddSection (new DebugAbbrevSection (desc));
1786
- obj->AddSection (new DebugLineSection (desc));
1795
+ obj->AddSection (new (zone) DebugInfoSection (desc), zone );
1796
+ obj->AddSection (new (zone) DebugAbbrevSection (desc), zone );
1797
+ obj->AddSection (new (zone) DebugLineSection (desc), zone );
1787
1798
}
1788
1799
#ifdef V8_TARGET_ARCH_X64
1789
- obj->AddSection (new UnwindInfoSection (desc));
1800
+ obj->AddSection (new (zone) UnwindInfoSection (desc), zone );
1790
1801
#endif
1791
1802
}
1792
1803
@@ -1905,7 +1916,8 @@ static void UnregisterCodeEntry(JITCodeEntry* entry) {
1905
1916
1906
1917
1907
1918
static JITCodeEntry* CreateELFObject (CodeDescription* desc) {
1908
- ZoneScope zone_scope (Isolate::Current (), DELETE_ON_EXIT);
1919
+ Zone* zone = desc->info ()->zone ();
1920
+ ZoneScope zone_scope (zone, DELETE_ON_EXIT);
1909
1921
#ifdef __MACH_O
1910
1922
MachO mach_o;
1911
1923
Writer w (&mach_o);
@@ -1918,17 +1930,19 @@ static JITCodeEntry* CreateELFObject(CodeDescription* desc) {
1918
1930
1919
1931
mach_o.Write (&w, desc->CodeStart (), desc->CodeSize ());
1920
1932
#else
1921
- ELF elf;
1933
+ ELF elf (zone) ;
1922
1934
Writer w (&elf);
1923
1935
1924
1936
int text_section_index = elf.AddSection (
1925
- new FullHeaderELFSection (" .text" ,
1926
- ELFSection::TYPE_NOBITS,
1927
- kCodeAlignment ,
1928
- desc->CodeStart (),
1929
- 0 ,
1930
- desc->CodeSize (),
1931
- ELFSection::FLAG_ALLOC | ELFSection::FLAG_EXEC));
1937
+ new (zone) FullHeaderELFSection (
1938
+ " .text" ,
1939
+ ELFSection::TYPE_NOBITS,
1940
+ kCodeAlignment ,
1941
+ desc->CodeStart (),
1942
+ 0 ,
1943
+ desc->CodeSize (),
1944
+ ELFSection::FLAG_ALLOC | ELFSection::FLAG_EXEC),
1945
+ zone);
1932
1946
1933
1947
CreateSymbolsTable (desc, &elf, text_section_index);
1934
1948
0 commit comments