Changeset 236305 in webkit for trunk/Source/JavaScriptCore/jsc.cpp
- Timestamp:
- Sep 20, 2018, 9:36:08 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jsc.cpp
r236293 r236305 128 128 #endif 129 129 130 #if __has_include(<WebKitAdditions/MemoryFootprint.h>)131 #include <WebKitAdditions/MemoryFootprint.h>132 #else133 struct MemoryFootprint {134 uint64_t current;135 uint64_t peak;136 137 static MemoryFootprint now()138 {139 return { 0L, 0L };140 }141 142 static void resetPeak()143 {144 }145 };146 #endif147 148 130 #if !defined(PATH_MAX) 149 131 #define PATH_MAX 4096 … … 286 268 static EncodedJSValue JSC_HOST_CALL functionForceGCSlowPaths(ExecState*); 287 269 static EncodedJSValue JSC_HOST_CALL functionHeapSize(ExecState*); 288 static EncodedJSValue JSC_HOST_CALL functionCreateMemoryFootprint(ExecState*);289 static EncodedJSValue JSC_HOST_CALL functionResetMemoryPeak(ExecState*);290 270 static EncodedJSValue JSC_HOST_CALL functionAddressOf(ExecState*); 291 271 static EncodedJSValue JSC_HOST_CALL functionVersion(ExecState*); … … 505 485 addFunction(vm, "forceGCSlowPaths", functionForceGCSlowPaths, 0); 506 486 addFunction(vm, "gcHeapSize", functionHeapSize, 0); 507 addFunction(vm, "MemoryFootprint", functionCreateMemoryFootprint, 0);508 addFunction(vm, "resetMemoryPeak", functionResetMemoryPeak, 0);509 487 addFunction(vm, "addressOf", functionAddressOf, 1); 510 488 addFunction(vm, "version", functionVersion, 1); … … 1202 1180 } 1203 1181 1204 class JSCMemoryFootprint : public JSDestructibleObject {1205 using Base = JSDestructibleObject;1206 public:1207 JSCMemoryFootprint(VM& vm, Structure* structure)1208 : Base(vm, structure)1209 { }1210 1211 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)1212 {1213 return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());1214 }1215 1216 static JSCMemoryFootprint* create(VM& vm, JSGlobalObject* globalObject)1217 {1218 Structure* structure = createStructure(vm, globalObject, jsNull());1219 JSCMemoryFootprint* footprint = new (NotNull, allocateCell<JSCMemoryFootprint>(vm.heap, sizeof(JSCMemoryFootprint))) JSCMemoryFootprint(vm, structure);1220 footprint->finishCreation(vm);1221 return footprint;1222 }1223 1224 void finishCreation(VM& vm)1225 {1226 Base::finishCreation(vm);1227 1228 auto addProperty = [&] (VM& vm, const char* name, JSValue value) {1229 JSCMemoryFootprint::addProperty(vm, name, value);1230 };1231 1232 MemoryFootprint footprint = MemoryFootprint::now();1233 1234 // Report sizes in KBytes so that values up to GB are still integers.1235 addProperty(vm, "current", jsNumber(footprint.current / 1024));1236 addProperty(vm, "peak", jsNumber(footprint.peak / 1024));1237 }1238 1239 DECLARE_INFO;1240 1241 private:1242 void addProperty(VM& vm, const char* name, JSValue value)1243 {1244 Identifier identifier = Identifier::fromString(&vm, name);1245 putDirect(vm, identifier, value);1246 }1247 };1248 1249 const ClassInfo JSCMemoryFootprint::s_info = { "MemoryFootprint", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCMemoryFootprint) };1250 1251 EncodedJSValue JSC_HOST_CALL functionCreateMemoryFootprint(ExecState* exec)1252 {1253 VM& vm = exec->vm();1254 JSLockHolder lock(vm);1255 return JSValue::encode(JSCMemoryFootprint::create(vm, exec->lexicalGlobalObject()));1256 }1257 1258 EncodedJSValue JSC_HOST_CALL functionResetMemoryPeak(ExecState*)1259 {1260 MemoryFootprint::resetPeak();1261 return JSValue::encode(jsUndefined());1262 }1263 1264 1182 // This function is not generally very helpful in 64-bit code as the tag and payload 1265 1183 // share a register. But in 32-bit JITed code the tag may not be checked if an
Note:
See TracChangeset
for help on using the changeset viewer.