Browse Source

Merge remote-tracking branch 'upstream/develop' into randomTestEfficiency

cl-refactor
CJentzsch 10 years ago
parent
commit
2d8f047291
  1. 1
      .gitignore
  2. 13
      cmake/EthCompilerSettings.cmake
  3. 10
      evmjit/libevmjit/Arith256.cpp
  4. 6
      evmjit/libevmjit/Cache.cpp
  5. 8
      evmjit/libevmjit/Ext.cpp
  6. 8
      evmjit/libevmjit/GasMeter.cpp
  7. 6
      evmjit/libevmjit/Runtime.cpp
  8. 26
      libjsqrc/ethereumjs/dist/ethereum.js
  9. 4
      libjsqrc/ethereumjs/dist/ethereum.js.map
  10. 2
      libjsqrc/ethereumjs/dist/ethereum.min.js
  11. 26
      libjsqrc/ethereumjs/lib/abi.js
  12. 2
      libp2p/Host.cpp
  13. 2
      libserpent/rewriteutils.cpp
  14. 2
      libserpent/util.cpp
  15. 0
      libsolidity/AST.h
  16. 4
      libsolidity/CompilerContext.cpp
  17. 6
      libsolidity/CompilerContext.h
  18. 2
      libsolidity/CompilerStack.cpp
  19. 2
      libsolidity/Types.h
  20. 6
      libsolidity/Utils.h
  21. 4
      mergeMaster.sh
  22. 4
      mix/qml/NewProjectDialog.qml
  23. 1
      mix/qml/ProjectList.qml
  24. 6
      mix/qml/js/ProjectModel.js
  25. 4
      test/SolidityEndToEndTest.cpp
  26. 2
      test/boostTest.cpp
  27. 2
      test/vm.cpp

1
.gitignore

@ -68,3 +68,4 @@ project.pbxproj
evmjit
doc/html
*.autosave
node_modules/

13
cmake/EthCompilerSettings.cmake

@ -28,8 +28,17 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# specify Exception Handling Model in msvc
set(CMAKE_C_FLAGS "/EHsc")
set(CMAKE_CXX_FLAGS "/EHsc")
# disable unknown pragma warning (4068)
# disable unsafe function warning (4996)
# disable decorated name length exceeded, name was truncated (4503)
# disable warning C4535: calling _set_se_translator() requires /EHa (for boost tests)
# declare Windows XP requirement
add_compile_options(/EHsc /wd4068 /wd4996 /wd4503 -D_WIN32_WINNT=0x0501)
# disable empty object file warning
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
# warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
# warning LNK4099: pdb was not found with lib
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099,4075")
# windows likes static
set(ETH_STATIC 1)

10
evmjit/libevmjit/Arith256.cpp

@ -178,7 +178,10 @@ extern "C"
auto arg1 = llvm2eth(*_arg1);
auto arg2 = llvm2eth(*_arg2);
auto arg3 = llvm2eth(*_arg3);
*o_result = eth2llvm(u256((bigint(arg1) * bigint(arg2)) % arg3));
if (arg3 != 0)
*o_result = eth2llvm(u256((bigint(arg1) * bigint(arg2)) % arg3));
else
*o_result = {};
}
EXPORT void arith_addmod(i256* _arg1, i256* _arg2, i256* _arg3, i256* o_result)
@ -186,7 +189,10 @@ extern "C"
auto arg1 = llvm2eth(*_arg1);
auto arg2 = llvm2eth(*_arg2);
auto arg3 = llvm2eth(*_arg3);
*o_result = eth2llvm(u256((bigint(arg1) + bigint(arg2)) % arg3));
if (arg3 != 0)
*o_result = eth2llvm(u256((bigint(arg1) + bigint(arg2)) % arg3));
else
*o_result = {};
}
}

6
evmjit/libevmjit/Cache.cpp

@ -45,8 +45,7 @@ std::unique_ptr<llvm::Module> Cache::getObject(std::string const& id)
{
auto module = std::unique_ptr<llvm::Module>(new llvm::Module(id, llvm::getGlobalContext()));
auto mainFuncType = llvm::FunctionType::get(llvm::IntegerType::get(llvm::getGlobalContext(), 32), {}, false);
auto func = llvm::Function::Create(mainFuncType, llvm::Function::ExternalLinkage, id, module.get());
(void)func;
llvm::Function::Create(mainFuncType, llvm::Function::ExternalLinkage, id, module.get());
}
return nullptr;
}
@ -69,9 +68,8 @@ void ObjectCache::notifyObjectCompiled(llvm::Module const* _module, llvm::Memory
cacheFile << _object->getBuffer();
}
llvm::MemoryBuffer* ObjectCache::getObject(llvm::Module const* _module)
llvm::MemoryBuffer* ObjectCache::getObject(llvm::Module const*)
{
(void)_module;
auto o = lastObject;
lastObject = nullptr;
return o;

8
evmjit/libevmjit/Ext.cpp

@ -22,11 +22,9 @@ namespace jit
Ext::Ext(RuntimeManager& _runtimeManager, Memory& _memoryMan):
RuntimeHelper(_runtimeManager),
m_memoryMan(_memoryMan)
// TODO: fix: either initialise properly or don't specify in constructor.
/*,
m_funcs{},
m_argAllocas{}*/
m_memoryMan(_memoryMan),
m_funcs({}), // The only std::array initialization that works in both Visual Studio & GCC
m_argAllocas({})
{
m_size = m_builder.CreateAlloca(Type::Size, nullptr, "env.size");
}

8
evmjit/libevmjit/GasMeter.cpp

@ -173,10 +173,12 @@ void GasMeter::countSha3Data(llvm::Value* _dataLength)
assert(m_blockCost > 0); // SHA3 instruction is already counted
// TODO: This round ups to 32 happens in many places
// FIXME: Overflow possible but Memory::require() also called. Probably 64-bit arith can be used.
// FIXME: 64-bit arith used, but not verified
static_assert(c_sha3WordGas != 1, "SHA3 data cost has changed. Update GasMeter");
auto words = m_builder.CreateUDiv(m_builder.CreateAdd(_dataLength, Constant::get(31)), Constant::get(32));
auto cost = m_builder.CreateNUWMul(Constant::get(c_sha3WordGas), words);
auto dataLength64 = getBuilder().CreateTrunc(_dataLength, Type::lowPrecision);
auto words64 = m_builder.CreateUDiv(m_builder.CreateAdd(dataLength64, getBuilder().getInt64(31)), getBuilder().getInt64(32));
auto cost64 = m_builder.CreateNUWMul(getBuilder().getInt64(c_sha3WordGas), words64);
auto cost = getBuilder().CreateZExt(cost64, Type::Word);
count(cost);
}

6
evmjit/libevmjit/Runtime.cpp

@ -24,8 +24,10 @@ bytes Runtime::getReturnData() const // FIXME: Reconsider returning by copy
auto offset = static_cast<size_t>(llvm2eth(m_data.elems[RuntimeData::ReturnDataOffset]));
auto size = static_cast<size_t>(llvm2eth(m_data.elems[RuntimeData::ReturnDataSize]));
assert(offset + size <= m_memory.size());
// TODO: Handle invalid data access by returning empty ref
assert(offset + size <= m_memory.size() || size == 0);
if (offset + size > m_memory.size())
return {};
auto dataBeg = m_memory.begin() + offset;
return {dataBeg, dataBeg + size};
}

26
libjsqrc/ethereumjs/dist/ethereum.js

@ -85,6 +85,18 @@ var calcRealPadding = function (type, expected) {
var setupInputTypes = function () {
// convert from int, decimal-string, prefixed hex string whatever into a bare hex string.
var formatStandard = function (value) {
if (typeof value === "number")
return value.toString(16);
else if (typeof value === "string" && value.indexOf('0x') === 0)
return value.substr(2);
else if (typeof value === "string")
return web3.toHex(value);
else
return (+value).toString(16);
};
var prefixedType = function (prefix, calcPadding) {
return function (type, value) {
var expected = prefix;
@ -99,15 +111,7 @@ var setupInputTypes = function () {
if (prefix === "string")
return web3.fromAscii(value, padding).substr(2);
if (typeof value === "number")
value = value.toString(16);
else if (typeof value === "string")
value = web3.toHex(value);
else if (value.indexOf('0x') === 0)
value = value.substr(2);
else
value = (+value).toString(16);
return padLeft(value, padding * 2);
return padLeft(formatStandard(value), padding * 2);
};
};
@ -124,7 +128,7 @@ var setupInputTypes = function () {
};
var formatBool = function (value) {
return value ? '0x1' : '0x0';
return value ? '01' : '00';
};
return [
@ -134,7 +138,7 @@ var setupInputTypes = function () {
prefixedType('string', calcBytePadding),
prefixedType('real', calcRealPadding),
prefixedType('ureal', calcRealPadding),
namedType('address', 20),
namedType('address', 20, formatStandard),
namedType('bool', 1, formatBool),
];
};

4
libjsqrc/ethereumjs/dist/ethereum.js.map

File diff suppressed because one or more lines are too long

2
libjsqrc/ethereumjs/dist/ethereum.min.js

File diff suppressed because one or more lines are too long

26
libjsqrc/ethereumjs/lib/abi.js

@ -84,6 +84,18 @@ var calcRealPadding = function (type, expected) {
var setupInputTypes = function () {
// convert from int, decimal-string, prefixed hex string whatever into a bare hex string.
var formatStandard = function (value) {
if (typeof value === "number")
return value.toString(16);
else if (typeof value === "string" && value.indexOf('0x') === 0)
return value.substr(2);
else if (typeof value === "string")
return web3.toHex(value);
else
return (+value).toString(16);
};
var prefixedType = function (prefix, calcPadding) {
return function (type, value) {
var expected = prefix;
@ -98,15 +110,7 @@ var setupInputTypes = function () {
if (prefix === "string")
return web3.fromAscii(value, padding).substr(2);
if (typeof value === "number")
value = value.toString(16);
else if (typeof value === "string")
value = web3.toHex(value);
else if (value.indexOf('0x') === 0)
value = value.substr(2);
else
value = (+value).toString(16);
return padLeft(value, padding * 2);
return padLeft(formatStandard(value), padding * 2);
};
};
@ -123,7 +127,7 @@ var setupInputTypes = function () {
};
var formatBool = function (value) {
return value ? '0x1' : '0x0';
return value ? '01' : '00';
};
return [
@ -133,7 +137,7 @@ var setupInputTypes = function () {
prefixedType('string', calcBytePadding),
prefixedType('real', calcRealPadding),
prefixedType('ureal', calcRealPadding),
namedType('address', 20),
namedType('address', 20, formatStandard),
namedType('bool', 1, formatBool),
];
};

2
libp2p/Host.cpp

@ -184,7 +184,7 @@ shared_ptr<Node> Host::noteNode(NodeId _id, bi::tcp::endpoint _a, Origin _o, boo
{
RecursiveGuard l(x_peers);
if (_a.port() < 30300 || _a.port() > 30305)
cwarn << "Weird port being recorded: " << _a.port();
cwarn << "Non-standard port being recorded: " << _a.port();
if (_a.port() >= /*49152*/32768)
{

2
libserpent/rewriteutils.cpp

@ -54,7 +54,7 @@ bool isValidFunctionName(std::string f) {
vfMap[validFunctions[i][0]] = true;
}
}
return vfMap.count(f);
return vfMap.count(f) != 0;
}
// Cool function for debug purposes (named cerrStringList to make

2
libserpent/util.cpp

@ -260,7 +260,7 @@ std::string get_file_contents(std::string filename)
{
std::string contents;
in.seekg(0, std::ios::end);
contents.resize(in.tellg());
contents.resize((unsigned)in.tellg());
in.seekg(0, std::ios::beg);
in.read(&contents[0], contents.size());
in.close();

0
libsolidity/AST.h

4
libsolidity/CompilerContext.cpp

@ -53,8 +53,8 @@ void CompilerContext::addAndInitializeVariable(VariableDeclaration const& _decla
{
addVariable(_declaration);
unsigned const size = _declaration.getType()->getSizeOnStack();
for (unsigned i = 0; i < size; ++i)
int const size = _declaration.getType()->getSizeOnStack();
for (int i = 0; i < size; ++i)
*this << u256(0);
m_asm.adjustDeposit(-size);
}

6
libsolidity/CompilerContext.h

@ -51,10 +51,10 @@ public:
void adjustStackOffset(int _adjustment) { m_asm.adjustDeposit(_adjustment); }
bool isMagicGlobal(Declaration const* _declaration) const { return m_magicGlobals.count(_declaration); }
bool isFunctionDefinition(Declaration const* _declaration) const { return m_functionEntryLabels.count(_declaration); }
bool isMagicGlobal(Declaration const* _declaration) const { return m_magicGlobals.count(_declaration) != 0; }
bool isFunctionDefinition(Declaration const* _declaration) const { return m_functionEntryLabels.count(_declaration) != 0; }
bool isLocalVariable(Declaration const* _declaration) const;
bool isStateVariable(Declaration const* _declaration) const { return m_stateVariables.count(_declaration); }
bool isStateVariable(Declaration const* _declaration) const { return m_stateVariables.count(_declaration) != 0; }
eth::AssemblyItem getFunctionEntryLabel(FunctionDefinition const& _function) const;
/// Returns the distance of the given local variable from the top of the local variable stack.

2
libsolidity/CompilerStack.cpp

@ -39,7 +39,7 @@ namespace solidity
bool CompilerStack::addSource(string const& _name, string const& _content)
{
bool existed = m_sources.count(_name);
bool existed = m_sources.count(_name) != 0;
reset(true);
m_sources[_name].scanner = make_shared<Scanner>(CharStream(_content), _name);
return existed;

2
libsolidity/Types.h

@ -178,7 +178,7 @@ public:
int getNumBits() const { return m_bits; }
bool isHash() const { return m_modifier == Modifier::HASH || m_modifier == Modifier::ADDRESS; }
bool isAddress() const { return m_modifier == Modifier::ADDRESS; }
int isSigned() const { return m_modifier == Modifier::SIGNED; }
bool isSigned() const { return m_modifier == Modifier::SIGNED; }
static const MemberList AddressMemberList;

6
libsolidity/Utils.h

@ -45,5 +45,11 @@ inline void solAssertAux(bool _condition, std::string const& _errorDescription,
<< ::boost::throw_line(_line));
}
inline void solAssertAux(void const* _pointer, std::string const& _errorDescription, unsigned _line,
char const* _file, char const* _function)
{
solAssertAux(_pointer != nullptr, _errorDescription, _line, _file, _function);
}
}
}

4
mergeMaster.sh

@ -0,0 +1,4 @@
#!/bin/bash
git checkout master && git merge --no-ff $1+ && git push && git tag -f $1 && git push --tags -f

4
mix/qml/NewProjectDialog.qml

@ -1,8 +1,8 @@
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Dialogs 1.1
Window {

1
mix/qml/ProjectList.qml

@ -80,7 +80,6 @@ Item {
hoverEnabled: true
z:2
onClicked: {
console.log("clicked");
textInput.forceActiveFocus();
}
}

6
mix/qml/js/ProjectModel.js

@ -90,7 +90,7 @@ function addFile(fileName) {
name: isContract ? "Contract" : fileName,
documentId: fileName,
isText: isContract || extension === ".html" || extension === ".js",
isContract: fileData,
isContract: isContract,
};
projectListModel.append(fileData);
@ -130,11 +130,11 @@ function doCreateProject(title, path) {
var contractsFile = "contracts.sol";
var projectData = {
title: title,
files: [ indexFile, contractsFile ]
files: [ contractsFile, indexFile ]
};
//TODO: copy from template
fileIo.writeFile(dirPath + indexFile, "<html></html>");
fileIo.writeFile(dirPath + contractsFile, "contract MyContract {\n }\n");
fileIo.writeFile(dirPath + contractsFile, "contract MyContract {\n}\n");
var json = JSON.stringify(projectData);
fileIo.writeFile(projectFile, json);
loadProject(dirPath);

4
test/SolidityEndToEndTest.cpp

@ -28,6 +28,10 @@
#include <libdevcrypto/SHA3.h>
#include <test/solidityExecutionFramework.h>
#ifdef _MSC_VER
#pragma warning(disable: 4307) //integral constant overflow for high_bits_cleaning
#endif
using namespace std;
namespace dev

2
test/boostTest.cpp

@ -23,6 +23,6 @@
#define BOOST_TEST_MODULE EthereumTests
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#define BOOST_DISABLE_WIN32 //disables SEH warning
#include <boost/test/included/unit_test.hpp>
#pragma warning(pop)
#pragma GCC diagnostic pop

2
test/vm.cpp

@ -345,7 +345,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
output = vm->go(fev, fev.simpleTrace()).toBytes();
gas = vm->gas();
}
catch (VMException const& _e)
catch (VMException const&)
{
cnote << "Safe VM Exception";
vmExceptionOccured = true;

Loading…
Cancel
Save