Changeset 212618 in webkit
- Timestamp:
- Feb 19, 2017, 5:46:04 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/JavaScriptCore/ChangeLog ¶
r212616 r212618 1 2017-02-19 Mark Lam <mark.lam@apple.com> 2 3 CachedCall should let GC know to keep its arguments alive. 4 https://bugs.webkit.org/show_bug.cgi?id=168567 5 <rdar://problem/30475767> 6 7 Reviewed by Saam Barati. 8 9 We fix this by having CachedCall use a MarkedArgumentBuffer to store its 10 arguments instead of a Vector. 11 12 Also declared CachedCall, MarkedArgumentBuffer, and ProtoCallFrame as 13 WTF_FORBID_HEAP_ALLOCATION because they rely on being stack allocated for 14 correctness. 15 16 * interpreter/CachedCall.h: 17 (JSC::CachedCall::CachedCall): 18 (JSC::CachedCall::call): 19 (JSC::CachedCall::clearArguments): 20 (JSC::CachedCall::appendArgument): 21 (JSC::CachedCall::setArgument): Deleted. 22 * interpreter/CallFrame.h: 23 (JSC::ExecState::emptyList): 24 * interpreter/Interpreter.cpp: 25 (JSC::Interpreter::prepareForRepeatCall): 26 * interpreter/Interpreter.h: 27 * interpreter/ProtoCallFrame.h: 28 * runtime/ArgList.cpp: 29 (JSC::MarkedArgumentBuffer::expandCapacity): 30 * runtime/ArgList.h: 31 (JSC::MarkedArgumentBuffer::ensureCapacity): 32 * runtime/StringPrototype.cpp: 33 (JSC::replaceUsingRegExpSearch): 34 * runtime/VM.cpp: 35 (JSC::VM::VM): 36 * runtime/VM.h: 37 1 38 2017-02-19 Commit Queue <commit-queue@webkit.org> 2 39 -
TabularUnified trunk/Source/JavaScriptCore/interpreter/CachedCall.h ¶
r206525 r212618 1 1 /* 2 * Copyright (C) 2009 , 2013, 2016Apple Inc. All rights reserved.2 * Copyright (C) 2009-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 #include "VMEntryScope.h" 35 35 #include "VMInlines.h" 36 #include <wtf/ForbidHeapAllocation.h> 36 37 37 38 namespace JSC { 38 39 class CachedCall { 39 WTF_MAKE_NONCOPYABLE(CachedCall); WTF_MAKE_FAST_ALLOCATED; 40 WTF_MAKE_NONCOPYABLE(CachedCall); 41 WTF_FORBID_HEAP_ALLOCATION; 40 42 public: 41 43 CachedCall(CallFrame* callFrame, JSFunction* function, int argumentCount) … … 50 52 ASSERT(!function->isHostFunctionNonInline()); 51 53 if (UNLIKELY(vm.isSafeToRecurseSoft())) { 52 m_arguments. resize(argumentCount);53 m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, &m_protoCallFrame, function, argumentCount + 1, function->scope(), m_arguments .data());54 m_arguments.ensureCapacity(argumentCount); 55 m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, &m_protoCallFrame, function, argumentCount + 1, function->scope(), m_arguments); 54 56 } else 55 57 throwStackOverflowError(callFrame, scope); … … 60 62 { 61 63 ASSERT(m_valid); 64 ASSERT(m_arguments.size() == static_cast<size_t>(m_protoCallFrame.argumentCount())); 62 65 return m_interpreter->execute(m_closure); 63 66 } 64 67 void setThis(JSValue v) { m_protoCallFrame.setThisValue(v); } 65 void setArgument(int n, JSValue v) { m_protoCallFrame.setArgument(n, v); } 68 69 void clearArguments() { m_arguments.clear(); } 70 void appendArgument(JSValue v) { m_arguments.append(v); } 66 71 67 72 private: … … 71 76 VMEntryScope m_entryScope; 72 77 ProtoCallFrame m_protoCallFrame; 73 Vector<JSValue>m_arguments;78 MarkedArgumentBuffer m_arguments; 74 79 CallFrameClosure m_closure; 75 80 }; -
TabularUnified trunk/Source/JavaScriptCore/interpreter/CallFrame.h ¶
r212483 r212618 2 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 4 * Copyright (C) 2003 , 2007-2008, 2011, 2013-2016Apple Inc. All rights reserved.4 * Copyright (C) 2003-2017 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 120 120 AtomicStringTable* atomicStringTable() const { return vm().atomicStringTable(); } 121 121 const CommonIdentifiers& propertyNames() const { return *vm().propertyNames; } 122 const MarkedArgumentBuffer& emptyList() const { return *vm().emptyList; }122 const ArgList& emptyList() const { return *vm().emptyList; } 123 123 Interpreter* interpreter() { return vm().interpreter; } 124 124 Heap* heap() { return &vm().heap; } -
TabularUnified trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp ¶
r211642 r212618 1 1 /* 2 * Copyright (C) 2008-201 0, 2012-2016Apple Inc. All rights reserved.2 * Copyright (C) 2008-2017 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> 4 4 * … … 1006 1006 } 1007 1007 1008 CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* functionExecutable, CallFrame* callFrame, ProtoCallFrame* protoCallFrame, JSFunction* function, int argumentCountIncludingThis, JSScope* scope, JSValue*args)1008 CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* functionExecutable, CallFrame* callFrame, ProtoCallFrame* protoCallFrame, JSFunction* function, int argumentCountIncludingThis, JSScope* scope, const ArgList& args) 1009 1009 { 1010 1010 VM& vm = *scope->vm(); … … 1026 1026 size_t argsCount = argumentCountIncludingThis; 1027 1027 1028 protoCallFrame->init(newCodeBlock, function, jsUndefined(), argsCount, args );1028 protoCallFrame->init(newCodeBlock, function, jsUndefined(), argsCount, args.data()); 1029 1029 // Return the successful closure: 1030 1030 CallFrameClosure result = { callFrame, protoCallFrame, function, functionExecutable, &vm, scope, newCodeBlock->numParameters(), argumentCountIncludingThis }; -
TabularUnified trunk/Source/JavaScriptCore/interpreter/Interpreter.h ¶
r211642 r212618 1 1 /* 2 * Copyright (C) 2008 , 2013, 2015-2016Apple Inc. All rights reserved.2 * Copyright (C) 2008-2017 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 4 4 * … … 155 155 enum ExecutionFlag { Normal, InitializeAndReturn }; 156 156 157 CallFrameClosure prepareForRepeatCall(FunctionExecutable*, CallFrame*, ProtoCallFrame*, JSFunction*, int argumentCountIncludingThis, JSScope*, JSValue*);157 CallFrameClosure prepareForRepeatCall(FunctionExecutable*, CallFrame*, ProtoCallFrame*, JSFunction*, int argumentCountIncludingThis, JSScope*, const ArgList&); 158 158 159 159 JSValue execute(CallFrameClosure&); -
TabularUnified trunk/Source/JavaScriptCore/interpreter/ProtoCallFrame.h ¶
r206525 r212618 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All Rights Reserved.2 * Copyright (C) 2013-2017 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 28 28 #include "Register.h" 29 #include <wtf/ForbidHeapAllocation.h> 29 30 30 31 namespace JSC { 31 32 32 33 struct JS_EXPORT_PRIVATE ProtoCallFrame { 34 WTF_FORBID_HEAP_ALLOCATION; 35 public: 33 36 Register codeBlockValue; 34 37 Register calleeValue; -
TabularUnified trunk/Source/JavaScriptCore/runtime/ArgList.cpp ¶
r209897 r212618 1 1 /* 2 * Copyright (C) 2003 , 2004, 2005, 2006, 2007, 2009, 2016Apple Inc. All rights reserved.2 * Copyright (C) 2003-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 64 64 } 65 65 66 void MarkedArgumentBuffer::slowEnsureCapacity(size_t requestedCapacity) 67 { 68 int newCapacity = Checked<int>(requestedCapacity).unsafeGet(); 69 expandCapacity(newCapacity); 70 } 71 66 72 void MarkedArgumentBuffer::expandCapacity() 67 73 { 68 74 int newCapacity = (Checked<int>(m_capacity) * 2).unsafeGet(); 75 expandCapacity(newCapacity); 76 } 77 78 void MarkedArgumentBuffer::expandCapacity(int newCapacity) 79 { 80 ASSERT(m_capacity < newCapacity); 69 81 size_t size = (Checked<size_t>(newCapacity) * sizeof(EncodedJSValue)).unsafeGet(); 70 82 EncodedJSValue* newBuffer = static_cast<EncodedJSValue*>(fastMalloc(size)); -
TabularUnified trunk/Source/JavaScriptCore/runtime/ArgList.h ¶
r209897 r212618 1 1 /* 2 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 * Copyright (C) 2003 , 2007, 2008, 2009, 2016Apple Inc. All rights reserved.3 * Copyright (C) 2003-2017 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 23 23 24 24 #include "CallFrame.h" 25 #include <wtf/ForbidHeapAllocation.h> 25 26 #include <wtf/HashSet.h> 26 27 … … 29 30 class MarkedArgumentBuffer { 30 31 WTF_MAKE_NONCOPYABLE(MarkedArgumentBuffer); 32 WTF_FORBID_HEAP_ALLOCATION; 31 33 friend class VM; 32 34 friend class ArgList; … … 95 97 static void markLists(SlotVisitor&, ListSet&); 96 98 99 void ensureCapacity(size_t requestedCapacity) 100 { 101 if (requestedCapacity > static_cast<size_t>(m_capacity)) 102 slowEnsureCapacity(requestedCapacity); 103 } 104 97 105 private: 98 106 void expandCapacity(); 107 void expandCapacity(int newCapacity); 108 void slowEnsureCapacity(size_t requestedCapacity); 99 109 100 110 void addMarkSet(JSValue); -
TabularUnified trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp ¶
r211247 r212618 1 1 /* 2 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 * Copyright (C) 2004-20 08, 2013, 2016Apple Inc. All rights reserved.3 * Copyright (C) 2004-2017 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2009 Torch Mobile, Inc. 5 5 * Copyright (C) 2015 Jordan Harband (ljharb@gmail.com) … … 540 540 541 541 unsigned i = 0; 542 cachedCall.clearArguments(); 542 543 for (; i < regExp->numSubpatterns() + 1; ++i) { 543 544 int matchStart = ovector[i * 2]; … … 545 546 546 547 if (matchStart < 0) 547 cachedCall. setArgument(i,jsUndefined());548 cachedCall.appendArgument(jsUndefined()); 548 549 else 549 cachedCall. setArgument(i,jsSubstring(&vm, source, matchStart, matchLen));550 cachedCall.appendArgument(jsSubstring(&vm, source, matchStart, matchLen)); 550 551 } 551 552 552 cachedCall. setArgument(i++,jsNumber(result.start));553 cachedCall. setArgument(i++,string);553 cachedCall.appendArgument(jsNumber(result.start)); 554 cachedCall.appendArgument(string); 554 555 555 556 cachedCall.setThis(jsUndefined()); … … 579 580 580 581 unsigned i = 0; 582 cachedCall.clearArguments(); 581 583 for (; i < regExp->numSubpatterns() + 1; ++i) { 582 584 int matchStart = ovector[i * 2]; … … 584 586 585 587 if (matchStart < 0) 586 cachedCall. setArgument(i,jsUndefined());588 cachedCall.appendArgument(jsUndefined()); 587 589 else 588 cachedCall. setArgument(i,jsSubstring(&vm, source, matchStart, matchLen));590 cachedCall.appendArgument(jsSubstring(&vm, source, matchStart, matchLen)); 589 591 } 590 592 591 cachedCall. setArgument(i++,jsNumber(result.start));592 cachedCall. setArgument(i++,string);593 cachedCall.appendArgument(jsNumber(result.start)); 594 cachedCall.appendArgument(string); 593 595 594 596 cachedCall.setThis(jsUndefined()); -
TabularUnified trunk/Source/JavaScriptCore/runtime/VM.cpp ¶
r212365 r212618 181 181 , m_atomicStringTable(vmType == Default ? wtfThreadData().atomicStringTable() : new AtomicStringTable) 182 182 , propertyNames(nullptr) 183 , emptyList(new MarkedArgumentBuffer)183 , emptyList(new ArgList) 184 184 , machineCodeBytesPerBytecodeWordForBaselineJIT(std::make_unique<SimpleStats>()) 185 185 , customGetterSetterFunctionMap(*this) -
TabularUnified trunk/Source/JavaScriptCore/runtime/VM.h ¶
r212365 r212618 386 386 TemplateRegistryKeyTable m_templateRegistryKeytable; 387 387 CommonIdentifiers* propertyNames; 388 const MarkedArgumentBuffer* emptyList; // Lists are supposed to be allocated on the stack to have their elements properly marked, which is not the case here - but this list has nothing to mark.388 const ArgList* emptyList; 389 389 SmallStrings smallStrings; 390 390 NumericStrings numericStrings; -
TabularUnified trunk/Source/WTF/ChangeLog ¶
r212616 r212618 1 2017-02-19 Mark Lam <mark.lam@apple.com> 2 3 CachedCall should let GC know to keep its arguments alive. 4 https://bugs.webkit.org/show_bug.cgi?id=168567 5 <rdar://problem/30475767> 6 7 Reviewed by Saam Barati. 8 9 Added a WTF_FORBID_HEAP_ALLOCATION that will cause a compilation failure if 10 a class declared with it is malloced. 11 12 While this doesn't prevent that class declared WTF_FORBID_HEAP_ALLOCATION from 13 being embedded in another class that is heap allocated, it does at minimum 14 document the intent and gives the users of this class a chance to do the 15 right thing. 16 17 * WTF.xcodeproj/project.pbxproj: 18 * wtf/ForbidHeapAllocation.h: Added. 19 1 20 2017-02-19 Commit Queue <commit-queue@webkit.org> 2 21 -
TabularUnified trunk/Source/WTF/WTF.xcodeproj/project.pbxproj ¶
r212180 r212618 369 369 EB95E1F0161A72410089A2F5 /* ByteOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = EB95E1EF161A72410089A2F5 /* ByteOrder.h */; }; 370 370 FE8225311B2A1E5B00BA68FD /* NakedPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8225301B2A1E5B00BA68FD /* NakedPtr.h */; }; 371 FE86A8751E59440200111BBF /* ForbidHeapAllocation.h in Headers */ = {isa = PBXBuildFile; fileRef = FE86A8741E59440200111BBF /* ForbidHeapAllocation.h */; }; 371 372 FE8925B01D00DAEC0046907E /* Indenter.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8925AF1D00DAEC0046907E /* Indenter.h */; }; 372 373 FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; }; … … 752 753 F72BBDB107FA424886178B9E /* SymbolImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolImpl.cpp; sourceTree = "<group>"; }; 753 754 FE8225301B2A1E5B00BA68FD /* NakedPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NakedPtr.h; sourceTree = "<group>"; }; 755 FE86A8741E59440200111BBF /* ForbidHeapAllocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForbidHeapAllocation.h; sourceTree = "<group>"; }; 754 756 FE8925AF1D00DAEC0046907E /* Indenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Indenter.h; sourceTree = "<group>"; }; 755 757 FEDACD3B1630F83F00C69634 /* StackStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackStats.cpp; sourceTree = "<group>"; }; … … 963 965 0F9D335C165DBA73005AD387 /* FilePrintStream.h */, 964 966 0F2B66A517B6B4F700A7AE3F /* FlipBytes.h */, 967 FE86A8741E59440200111BBF /* ForbidHeapAllocation.h */, 965 968 A8A472A6151A825A004123FF /* Forward.h */, 966 969 83F2BADE1CF9524E003E99C3 /* Function.h */, … … 1419 1422 1A1D8B9C173186CE00141DA4 /* FunctionDispatcher.h in Headers */, 1420 1423 A8A473CA151A825B004123FF /* GetPtr.h in Headers */, 1424 FE86A8751E59440200111BBF /* ForbidHeapAllocation.h in Headers */, 1421 1425 0FEC84AF1BD825310080FF74 /* GraphNodeWorklist.h in Headers */, 1422 1426 2C05385415BC819000F21B96 /* GregorianDateTime.h in Headers */,
Note:
See TracChangeset
for help on using the changeset viewer.