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