Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSSL float backports for 8.x and 6.x #24354

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions deps/openssl/openssl/crypto/dsa/dsa_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len,
DSA_SIG *sig, DSA *dsa);
static int dsa_init(DSA *dsa);
static int dsa_finish(DSA *dsa);
static BIGNUM *dsa_mod_inverse_fermat(const BIGNUM *k, const BIGNUM *q,
BN_CTX *ctx);

static DSA_METHOD openssl_dsa_meth = {
"OpenSSL DSA method",
Expand Down Expand Up @@ -279,7 +281,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
goto err;

/* Preallocate space */
q_bits = BN_num_bits(dsa->q);
q_bits = BN_num_bits(dsa->q) + sizeof(dsa->q->d[0]) * 16;
if (!BN_set_bit(&k, q_bits)
|| !BN_set_bit(&l, q_bits)
|| !BN_set_bit(&m, q_bits))
Expand All @@ -293,9 +295,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,

if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) {
BN_set_flags(&k, BN_FLG_CONSTTIME);
BN_set_flags(&l, BN_FLG_CONSTTIME);
}


if (dsa->flags & DSA_FLAG_CACHE_MONT_P) {
if (!BN_MONT_CTX_set_locked(&dsa->method_mont_p,
CRYPTO_LOCK_DSA, dsa->p, ctx))
Expand Down Expand Up @@ -333,8 +335,8 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
if (!BN_mod(r, r, dsa->q, ctx))
goto err;

/* Compute part of 's = inv(k) (m + xr) mod q' */
if ((kinv = BN_mod_inverse(NULL, &k, dsa->q, ctx)) == NULL)
/* Compute part of 's = inv(k) (m + xr) mod q' */
if ((kinv = dsa_mod_inverse_fermat(&k, dsa->q, ctx)) == NULL)
goto err;

if (*kinvp != NULL)
Expand Down Expand Up @@ -468,3 +470,31 @@ static int dsa_finish(DSA *dsa)
BN_MONT_CTX_free(dsa->method_mont_p);
return (1);
}

/*
* Compute the inverse of k modulo q.
* Since q is prime, Fermat's Little Theorem applies, which reduces this to
* mod-exp operation. Both the exponent and modulus are public information
* so a mod-exp that doesn't leak the base is sufficient. A newly allocated
* BIGNUM is returned which the caller must free.
*/
static BIGNUM *dsa_mod_inverse_fermat(const BIGNUM *k, const BIGNUM *q,
BN_CTX *ctx)
{
BIGNUM *res = NULL;
BIGNUM *r, e;

if ((r = BN_new()) == NULL)
return NULL;

BN_init(&e);

if (BN_set_word(r, 2)
&& BN_sub(&e, q, r)
&& BN_mod_exp_mont(r, k, &e, q, ctx, NULL))
res = r;
else
BN_free(r);
BN_free(&e);
return res;
}
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 6
#define V8_MINOR_VERSION 2
#define V8_BUILD_NUMBER 414
#define V8_PATCH_LEVEL 70
#define V8_PATCH_LEVEL 73

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
7 changes: 3 additions & 4 deletions deps/v8/src/base/debug/stack_trace_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const char kMangledSymbolPrefix[] = "_Z";
const char kSymbolCharacters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";

#if HAVE_EXECINFO_H
// Demangles C++ symbols in the given text. Example:
//
// "out/Debug/base_unittests(_ZN10StackTraceC1Ev+0x20) [0x817778c]"
Expand All @@ -81,7 +82,6 @@ void DemangleSymbols(std::string* text) {
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).

#if HAVE_EXECINFO_H

std::string::size_type search_from = 0;
while (search_from < text->size()) {
Expand Down Expand Up @@ -117,9 +117,8 @@ void DemangleSymbols(std::string* text) {
search_from = mangled_start + 2;
}
}

#endif // HAVE_EXECINFO_H
}
#endif // HAVE_EXECINFO_H

class BacktraceOutputHandler {
public:
Expand All @@ -129,6 +128,7 @@ class BacktraceOutputHandler {
virtual ~BacktraceOutputHandler() {}
};

#if HAVE_EXECINFO_H
void OutputPointer(void* pointer, BacktraceOutputHandler* handler) {
// This should be more than enough to store a 64-bit number in hex:
// 16 hex digits + 1 for null-terminator.
Expand All @@ -139,7 +139,6 @@ void OutputPointer(void* pointer, BacktraceOutputHandler* handler) {
handler->HandleOutput(buf);
}

#if HAVE_EXECINFO_H
void ProcessBacktrace(void* const* trace, size_t size,
BacktraceOutputHandler* handler) {
// NOTE: This code MUST be async-signal safe (it's used by in-process
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/compiler/bytecode-graph-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ Node* BytecodeGraphBuilder::Environment::Checkpoint(
BytecodeGraphBuilder::BytecodeGraphBuilder(
Zone* local_zone, Handle<SharedFunctionInfo> shared_info,
Handle<FeedbackVector> feedback_vector, BailoutId osr_offset,
JSGraph* jsgraph, CallFrequency invocation_frequency,
JSGraph* jsgraph, CallFrequency& invocation_frequency,
SourcePositionTable* source_positions, int inlining_id,
JSTypeHintLowering::Flags flags, bool stack_check)
: local_zone_(local_zone),
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/compiler/bytecode-graph-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BytecodeGraphBuilder {
BytecodeGraphBuilder(
Zone* local_zone, Handle<SharedFunctionInfo> shared,
Handle<FeedbackVector> feedback_vector, BailoutId osr_offset,
JSGraph* jsgraph, CallFrequency invocation_frequency,
JSGraph* jsgraph, CallFrequency& invocation_frequency,
SourcePositionTable* source_positions,
int inlining_id = SourcePosition::kNotInlined,
JSTypeHintLowering::Flags flags = JSTypeHintLowering::kNoFlags,
Expand Down
3 changes: 2 additions & 1 deletion deps/v8/src/compiler/js-inlining.cc
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,10 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
if (info_->is_bailout_on_uninitialized()) {
flags |= JSTypeHintLowering::kBailoutOnUninitialized;
}
CallFrequency frequency = call.frequency();
BytecodeGraphBuilder graph_builder(
zone(), shared_info, feedback_vector, BailoutId::None(), jsgraph(),
call.frequency(), source_positions_, inlining_id, flags, false);
frequency, source_positions_, inlining_id, flags, false);
graph_builder.CreateGraph();

// Extract the inlinee start/end nodes.
Expand Down
6 changes: 4 additions & 2 deletions deps/v8/src/compiler/js-operator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ const Operator* JSOperatorBuilder::CallForwardVarargs(size_t arity,
parameters); // parameter
}

const Operator* JSOperatorBuilder::Call(size_t arity, CallFrequency frequency,
const Operator* JSOperatorBuilder::Call(size_t arity,
CallFrequency const& frequency,
VectorSlotPair const& feedback,
ConvertReceiverMode convert_mode) {
CallParameters parameters(arity, frequency, feedback, convert_mode);
Expand All @@ -751,7 +752,8 @@ const Operator* JSOperatorBuilder::CallWithArrayLike(CallFrequency frequency) {
}

const Operator* JSOperatorBuilder::CallWithSpread(
uint32_t arity, CallFrequency frequency, VectorSlotPair const& feedback) {
uint32_t arity, CallFrequency const& frequency,
VectorSlotPair const& feedback) {
CallParameters parameters(arity, frequency, feedback,
ConvertReceiverMode::kAny);
return new (zone()) Operator1<CallParameters>( // --
Expand Down
8 changes: 4 additions & 4 deletions deps/v8/src/compiler/js-operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ CallForwardVarargsParameters const& CallForwardVarargsParametersOf(
// used as a parameter by JSCall and JSCallWithSpread operators.
class CallParameters final {
public:
CallParameters(size_t arity, CallFrequency frequency,
CallParameters(size_t arity, CallFrequency const& frequency,
VectorSlotPair const& feedback,
ConvertReceiverMode convert_mode)
: bit_field_(ArityField::encode(arity) |
Expand All @@ -201,7 +201,7 @@ class CallParameters final {
feedback_(feedback) {}

size_t arity() const { return ArityField::decode(bit_field_); }
CallFrequency frequency() const { return frequency_; }
CallFrequency const& frequency() const { return frequency_; }
ConvertReceiverMode convert_mode() const {
return ConvertReceiverModeField::decode(bit_field_);
}
Expand Down Expand Up @@ -647,12 +647,12 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final

const Operator* CallForwardVarargs(size_t arity, uint32_t start_index);
const Operator* Call(
size_t arity, CallFrequency frequency = CallFrequency(),
size_t arity, CallFrequency const& frequency = CallFrequency(),
VectorSlotPair const& feedback = VectorSlotPair(),
ConvertReceiverMode convert_mode = ConvertReceiverMode::kAny);
const Operator* CallWithArrayLike(CallFrequency frequency);
const Operator* CallWithSpread(
uint32_t arity, CallFrequency frequency = CallFrequency(),
uint32_t arity, CallFrequency const& frequency = CallFrequency(),
VectorSlotPair const& feedback = VectorSlotPair());
const Operator* CallRuntime(Runtime::FunctionId id);
const Operator* CallRuntime(Runtime::FunctionId id, size_t arity);
Expand Down
3 changes: 2 additions & 1 deletion deps/v8/src/compiler/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -890,10 +890,11 @@ struct GraphBuilderPhase {
if (data->info()->is_bailout_on_uninitialized()) {
flags |= JSTypeHintLowering::kBailoutOnUninitialized;
}
CallFrequency frequency = CallFrequency(1.0f);
BytecodeGraphBuilder graph_builder(
temp_zone, data->info()->shared_info(),
handle(data->info()->closure()->feedback_vector()),
data->info()->osr_offset(), data->jsgraph(), CallFrequency(1.0f),
data->info()->osr_offset(), data->jsgraph(), frequency,
data->source_positions(), SourcePosition::kNotInlined, flags);
graph_builder.CreateGraph();
}
Expand Down
6 changes: 6 additions & 0 deletions deps/v8/src/compiler/store-store-elimination.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ void StoreStoreElimination::Run(JSGraph* js_graph, Zone* temp_zone) {
}
}

#if V8_OS_AIX
ALLOW_UNUSED_TYPE
#endif
bool RedundantStoreFinder::IsEffectful(Node* node) {
return (node->op()->EffectInputCount() >= 1);
}
Expand Down Expand Up @@ -552,6 +555,9 @@ bool UnobservableStore::operator==(const UnobservableStore other) const {
return (id_ == other.id_) && (offset_ == other.offset_);
}

#if V8_OS_AIX
ALLOW_UNUSED_TYPE
#endif
bool UnobservableStore::operator!=(const UnobservableStore other) const {
return !(*this == other);
}
Expand Down
6 changes: 6 additions & 0 deletions deps/v8/src/conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ class StringCharacterStreamIterator {
};


#if V8_OS_AIX
ALLOW_UNUSED_TYPE
#endif
StringCharacterStreamIterator::StringCharacterStreamIterator(
StringCharacterStream* stream) : stream_(stream) {
++(*this);
}

#if V8_OS_AIX
ALLOW_UNUSED_TYPE
#endif
uint16_t StringCharacterStreamIterator::operator*() const {
return current_;
}
Expand Down
4 changes: 4 additions & 0 deletions deps/v8/testing/gtest.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
'action????': ['$(TargetPath)', '--gtest_print_time'],
},
}],
['OS=="aix"', {
'cflags': [ '-Wno-nonnull-compare',
'-Wno-address' ],
}],
],
}],
],
Expand Down