Changeset 166013 in webkit
- Timestamp:
- Mar 20, 2014 4:08:30 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r165999 r166013 1 2014-03-20 Filip Pizlo <fpizlo@apple.com> 2 3 Implement stackmap header version check and support new stackmap formats 4 https://bugs.webkit.org/show_bug.cgi?id=130535 5 <rdar://problem/16164284> 6 7 Reviewed by Geoffrey Garen. 8 9 Add the notion of versioning so that LLVMers can happily implement new stackmap formats 10 without worrying about WebKit getting version-locked to LLVM. In the future, we will have 11 to implement parsing for a new LLVM stackmap format before it lands in LLVM, or we'll have 12 to have a "max usable LLVM revision" limit. But, thanks to versioning, we'll always be 13 happy to move backward in time to older versions of LLVM. 14 15 * ftl/FTLStackMaps.cpp: 16 (JSC::FTL::readObject): 17 (JSC::FTL::StackMaps::Constant::parse): 18 (JSC::FTL::StackMaps::StackSize::parse): 19 (JSC::FTL::StackMaps::Location::parse): 20 (JSC::FTL::StackMaps::Record::parse): 21 (JSC::FTL::StackMaps::parse): 22 (JSC::FTL::StackMaps::dump): 23 (JSC::FTL::StackMaps::dumpMultiline): 24 * ftl/FTLStackMaps.h: 25 1 26 2014-03-20 Filip Pizlo <fpizlo@apple.com> 2 27 -
trunk/Source/JavaScriptCore/ftl/FTLStackMaps.cpp
r163842 r166013 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2014 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 38 38 template<typename T> 39 T readObject( DataView* view, unsigned& offset)39 T readObject(StackMaps::ParseContext& context) 40 40 { 41 41 T result; 42 result.parse( view, offset);42 result.parse(context); 43 43 return result; 44 44 } 45 45 46 void StackMaps::Constant::parse( DataView* view, unsigned& offset)47 { 48 integer = view->read<int64_t>(offset, true);46 void StackMaps::Constant::parse(StackMaps::ParseContext& context) 47 { 48 integer = context.view->read<int64_t>(context.offset, true); 49 49 } 50 50 … … 54 54 } 55 55 56 void StackMaps::StackSize::parse(DataView* view, unsigned& offset) 57 { 58 functionOffset = view->read<uint32_t>(offset, true); 59 size = view->read<uint32_t>(offset, true); 56 void StackMaps::StackSize::parse(StackMaps::ParseContext& context) 57 { 58 switch (context.version) { 59 case 0: 60 functionOffset = context.view->read<uint32_t>(context.offset, true); 61 size = context.view->read<uint32_t>(context.offset, true); 62 break; 63 64 default: 65 functionOffset = context.view->read<uint64_t>(context.offset, true); 66 size = context.view->read<uint64_t>(context.offset, true); 67 break; 68 } 60 69 } 61 70 … … 65 74 } 66 75 67 void StackMaps::Location::parse( DataView* view, unsigned& offset)68 { 69 kind = static_cast<Kind>( view->read<uint8_t>(offset, true));70 size = view->read<uint8_t>(offset, true);71 dwarfRegNum = view->read<uint16_t>(offset, true);72 this->offset = view->read<int32_t>(offset, true);76 void StackMaps::Location::parse(StackMaps::ParseContext& context) 77 { 78 kind = static_cast<Kind>(context.view->read<uint8_t>(context.offset, true)); 79 size = context.view->read<uint8_t>(context.offset, true); 80 dwarfRegNum = context.view->read<uint16_t>(context.offset, true); 81 this->offset = context.view->read<int32_t>(context.offset, true); 73 82 } 74 83 … … 89 98 } 90 99 91 bool StackMaps::Record::parse( DataView* view, unsigned& offset)92 { 93 int64_t id = view->read<int64_t>(offset, true);100 bool StackMaps::Record::parse(StackMaps::ParseContext& context) 101 { 102 int64_t id = context.view->read<int64_t>(context.offset, true); 94 103 ASSERT(static_cast<int32_t>(id) == id); 95 104 patchpointID = static_cast<uint32_t>(id); … … 97 106 return false; 98 107 99 instructionOffset = view->read<uint32_t>(offset, true);100 flags = view->read<uint16_t>(offset, true);101 102 unsigned length = view->read<uint16_t>(offset, true);108 instructionOffset = context.view->read<uint32_t>(context.offset, true); 109 flags = context.view->read<uint16_t>(context.offset, true); 110 111 unsigned length = context.view->read<uint16_t>(context.offset, true); 103 112 while (length--) 104 locations.append(readObject<Location>(view, offset)); 105 106 unsigned numLiveOuts = view->read<uint16_t>(offset, true); 113 locations.append(readObject<Location>(context)); 114 115 if (context.version >= 1) 116 context.view->read<uint16_t>(context.offset, true); // padding 117 unsigned numLiveOuts = context.view->read<uint16_t>(context.offset, true); 107 118 while (numLiveOuts--) { 108 view->read<uint16_t>(offset, true); // regnum 109 view->read<uint8_t>(offset, true); // reserved 110 view->read<uint8_t>(offset, true); // size in bytes 119 context.view->read<uint16_t>(context.offset, true); // regnum 120 context.view->read<uint8_t>(context.offset, true); // reserved 121 context.view->read<uint8_t>(context.offset, true); // size in bytes 122 } 123 if (context.version >= 1) { 124 if (context.offset & 7) { 125 ASSERT(!(context.offset & 3)); 126 context.view->read<uint32_t>(context.offset, true); // padding 127 } 111 128 } 112 129 … … 123 140 bool StackMaps::parse(DataView* view) 124 141 { 125 unsigned offset = 0; 126 127 view->read<uint32_t>(offset, true); // Reserved (header) 128 129 uint32_t numFunctions = view->read<uint32_t>(offset, true); 130 ASSERT(numFunctions == 1); // There should only be one stack size record 131 while (numFunctions--) { 132 stackSizes.append(readObject<StackSize>(view, offset)); 133 } 134 135 uint32_t numConstants = view->read<uint32_t>(offset, true); 142 ParseContext context; 143 context.offset = 0; 144 context.view = view; 145 146 version = context.version = context.view->read<uint8_t>(context.offset, true); 147 148 context.view->read<uint8_t>(context.offset, true); // Reserved 149 context.view->read<uint8_t>(context.offset, true); // Reserved 150 context.view->read<uint8_t>(context.offset, true); // Reserved 151 152 uint32_t numFunctions; 153 uint32_t numConstants; 154 uint32_t numRecords; 155 156 numFunctions = context.view->read<uint32_t>(context.offset, true); 157 if (context.version >= 1) { 158 numConstants = context.view->read<uint32_t>(context.offset, true); 159 numRecords = context.view->read<uint32_t>(context.offset, true); 160 } 161 while (numFunctions--) 162 stackSizes.append(readObject<StackSize>(context)); 163 164 if (!context.version) 165 numConstants = context.view->read<uint32_t>(context.offset, true); 136 166 while (numConstants--) 137 constants.append(readObject<Constant>(view, offset)); 138 139 uint32_t numRecords = view->read<uint32_t>(offset, true); 167 constants.append(readObject<Constant>(context)); 168 169 if (!context.version) 170 numRecords = context.view->read<uint32_t>(context.offset, true); 140 171 while (numRecords--) { 141 172 Record record; 142 if (!record.parse( view, offset))173 if (!record.parse(context)) 143 174 return false; 144 175 records.append(record); … … 150 181 void StackMaps::dump(PrintStream& out) const 151 182 { 152 out.print(" StackSizes[", listDump(stackSizes), "], Constants:[", listDump(constants), "], Records:[", listDump(records), "]");183 out.print("Version:", version, ", StackSizes[", listDump(stackSizes), "], Constants:[", listDump(constants), "], Records:[", listDump(records), "]"); 153 184 } 154 185 155 186 void StackMaps::dumpMultiline(PrintStream& out, const char* prefix) const 156 187 { 188 out.print(prefix, "Version: ", version, "\n"); 157 189 out.print(prefix, "StackSizes:\n"); 158 190 for (unsigned i = 0; i < stackSizes.size(); ++i) -
trunk/Source/JavaScriptCore/ftl/FTLStackMaps.h
r164424 r166013 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2014 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 40 40 41 41 struct StackMaps { 42 struct ParseContext { 43 unsigned version; 44 DataView* view; 45 unsigned offset; 46 }; 47 42 48 struct Constant { 43 49 int64_t integer; 44 50 45 void parse( DataView*, unsigned& offset);51 void parse(ParseContext&); 46 52 void dump(PrintStream& out) const; 47 53 }; 48 54 49 55 struct StackSize { 50 uint 32_t functionOffset;51 uint 32_t size;56 uint64_t functionOffset; 57 uint64_t size; 52 58 53 void parse( DataView*, unsigned& offset);59 void parse(ParseContext&); 54 60 void dump(PrintStream&) const; 55 61 }; … … 70 76 int32_t offset; 71 77 72 void parse( DataView*, unsigned& offset);78 void parse(ParseContext&); 73 79 void dump(PrintStream& out) const; 74 80 … … 84 90 Vector<Location> locations; 85 91 86 bool parse( DataView*, unsigned& offset);92 bool parse(ParseContext&); 87 93 void dump(PrintStream&) const; 88 94 }; 89 95 96 unsigned version; 90 97 Vector<StackSize> stackSizes; 91 98 Vector<Constant> constants;
Note: See TracChangeset
for help on using the changeset viewer.