Skip to content

Commit ecd7977

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm] Fix gcc build.
Change-Id: I8a0a9a695403dc6d048dccb9f33642d70cc5d588 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121866 Reviewed-by: Liam Appelbe <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 411bd62 commit ecd7977

22 files changed

+102
-71
lines changed

build/config/linux/BUILD.gn

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
import("//build/config/sysroot.gni")
66

77
config("sdk") {
8-
# Don't allow visible symbols from libc++ to be re-exported.
9-
ldflags = [
10-
"-nodefaultlibs",
11-
"-lc++",
12-
"-lc",
13-
"-lm",
14-
"-lpthread",
15-
"-lclang_rt.builtins",
16-
"-Wl,--exclude-libs=libc++.a",
17-
]
8+
ldflags = []
189

1910
if (is_asan || is_lsan || is_msan || is_tsan || is_ubsan) {
2011
ldflags += [ "-lrt" ]
12+
} else if (is_clang) {
13+
# Don't allow visible symbols from libc++ to be re-exported.
14+
ldflags = [
15+
"-nodefaultlibs",
16+
"-lc++",
17+
"-lc",
18+
"-lm",
19+
"-lpthread",
20+
"-lclang_rt.builtins",
21+
"-Wl,--exclude-libs=libc++.a",
22+
]
2123
}
2224

2325
if (sysroot != "") {

runtime/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ config("dart_config") {
168168
"-fno-exceptions",
169169
"-Wimplicit-fallthrough",
170170
]
171+
if (!is_clang) {
172+
cflags += [ "-Wno-cast-function-type" ]
173+
}
171174

172175
ldflags = []
173176
if (is_clang && dart_vm_code_coverage) {

runtime/bin/ffi_test/ffi_test_functions.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include <unistd.h>
1717

1818
// Only OK to use here because this is test code.
19+
#include <condition_variable> // NOLINT(build/c++11)
20+
#include <functional> // NOLINT(build/c++11)
21+
#include <mutex> // NOLINT(build/c++11)
1922
#include <thread> // NOLINT(build/c++11)
2023
#endif
2124

runtime/vm/class_table.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,12 @@ void SharedClassTable::Grow(intptr_t new_capacity) {
252252
memmove(new_table, table_, top_ * sizeof(intptr_t));
253253
memset(new_table + top_, 0, (new_capacity - top_) * sizeof(intptr_t));
254254
#ifndef PRODUCT
255-
auto new_stats_table = static_cast<ClassHeapStats*>(
256-
realloc(class_heap_stats_table_,
257-
new_capacity * sizeof(ClassHeapStats))); // NOLINT
255+
auto new_stats_table = reinterpret_cast<ClassHeapStats*>(
256+
malloc(new_capacity * sizeof(ClassHeapStats)));
257+
for (intptr_t i = 0; i < capacity_; i++) {
258+
new_stats_table[i] = class_heap_stats_table_[i];
259+
}
260+
free(class_heap_stats_table_);
258261
#endif
259262
for (intptr_t i = capacity_; i < new_capacity; i++) {
260263
new_table[i] = 0;

runtime/vm/compiler/aot/precompiler.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,13 +2274,12 @@ void PrecompileParsedFunctionHelper::FinalizeCompilation(
22742274
// to install code.
22752275
bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
22762276
ASSERT(FLAG_precompiled_mode);
2277-
const Function& function = parsed_function()->function();
2278-
if (optimized() && !function.IsOptimizable()) {
2277+
if (optimized() && !parsed_function()->function().IsOptimizable()) {
22792278
// All functions compiled by precompiler must be optimizable.
22802279
UNREACHABLE();
22812280
return false;
22822281
}
2283-
bool is_compiled = false;
2282+
volatile bool is_compiled = false;
22842283
Zone* const zone = thread()->zone();
22852284
HANDLESCOPE(thread());
22862285

@@ -2301,6 +2300,7 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
23012300
if (val == 0) {
23022301
FlowGraph* flow_graph = nullptr;
23032302
ZoneGrowableArray<const ICData*>* ic_data_array = nullptr;
2303+
const Function& function = parsed_function()->function();
23042304

23052305
CompilerState compiler_state(thread());
23062306

@@ -2314,7 +2314,7 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
23142314
}
23152315

23162316
if (optimized()) {
2317-
flow_graph->PopulateWithICData(parsed_function()->function());
2317+
flow_graph->PopulateWithICData(function);
23182318
}
23192319

23202320
const bool print_flow_graph =

runtime/vm/compiler/backend/flow_graph_compiler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ void FlowGraphCompiler::GenerateCidRangesCheck(
22702270

22712271
int bias = 0;
22722272
for (intptr_t i = 0; i < cid_ranges.length(); ++i) {
2273-
const CidRange& range = cid_ranges[i];
2273+
const CidRangeValue& range = cid_ranges[i];
22742274
RELEASE_ASSERT(!range.IsIllegalRange());
22752275
const bool last_round = i == (cid_ranges.length() - 1);
22762276

runtime/vm/compiler/backend/flow_graph_compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ class FlowGraphCompiler : public ValueObject {
872872
static int EmitTestAndCallCheckCid(compiler::Assembler* assembler,
873873
compiler::Label* label,
874874
Register class_id_reg,
875-
const CidRange& range,
875+
const CidRangeValue& range,
876876
int bias,
877877
bool jump_on_miss = true);
878878

runtime/vm/compiler/backend/flow_graph_compiler_arm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ void FlowGraphCompiler::EmitTestAndCallLoadCid(Register class_id_reg) {
13301330
int FlowGraphCompiler::EmitTestAndCallCheckCid(compiler::Assembler* assembler,
13311331
compiler::Label* label,
13321332
Register class_id_reg,
1333-
const CidRange& range,
1333+
const CidRangeValue& range,
13341334
int bias,
13351335
bool jump_on_miss) {
13361336
intptr_t cid_start = range.cid_start;

runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ void FlowGraphCompiler::EmitTestAndCallLoadCid(Register class_id_reg) {
12971297
int FlowGraphCompiler::EmitTestAndCallCheckCid(compiler::Assembler* assembler,
12981298
compiler::Label* label,
12991299
Register class_id_reg,
1300-
const CidRange& range,
1300+
const CidRangeValue& range,
13011301
int bias,
13021302
bool jump_on_miss) {
13031303
const intptr_t cid_start = range.cid_start;

runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ void FlowGraphCompiler::EmitTestAndCallLoadCid(Register class_id_reg) {
11851185
int FlowGraphCompiler::EmitTestAndCallCheckCid(compiler::Assembler* assembler,
11861186
compiler::Label* label,
11871187
Register class_id_reg,
1188-
const CidRange& range,
1188+
const CidRangeValue& range,
11891189
int bias,
11901190
bool jump_on_miss) {
11911191
intptr_t cid_start = range.cid_start;

runtime/vm/compiler/backend/flow_graph_compiler_x64.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ void FlowGraphCompiler::EmitTestAndCallLoadCid(Register class_id_reg) {
13021302
int FlowGraphCompiler::EmitTestAndCallCheckCid(compiler::Assembler* assembler,
13031303
compiler::Label* label,
13041304
Register class_id_reg,
1305-
const CidRange& range,
1305+
const CidRangeValue& range,
13061306
int bias,
13071307
bool jump_on_miss) {
13081308
// Note of WARNING: Due to smaller instruction encoding we use the 32-bit

runtime/vm/compiler/backend/il.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ bool HierarchyInfo::InstanceOfHasClassRange(const AbstractType& type,
466466
/*include_abstract=*/false,
467467
/*exclude_null=*/true);
468468
if (ranges.length() == 1) {
469-
const CidRange& range = ranges[0];
469+
const CidRangeValue& range = ranges[0];
470470
if (!range.IsIllegalRange()) {
471471
*lower_limit = range.cid_start;
472472
*upper_limit = range.cid_end;

runtime/vm/compiler/backend/il.h

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,33 @@ class Value : public ZoneAllocated {
177177
// Represents a range of class-ids for use in class checks and polymorphic
178178
// dispatches. The range includes both ends, i.e. it is [cid_start, cid_end].
179179
struct CidRange : public ZoneAllocated {
180-
CidRange(const CidRange& o)
181-
: ZoneAllocated(), cid_start(o.cid_start), cid_end(o.cid_end) {}
182180
CidRange(intptr_t cid_start_arg, intptr_t cid_end_arg)
183181
: cid_start(cid_start_arg), cid_end(cid_end_arg) {}
184182
CidRange() : cid_start(kIllegalCid), cid_end(kIllegalCid) {}
185183

186-
const CidRange& operator=(const CidRange& other) {
187-
cid_start = other.cid_start;
188-
cid_end = other.cid_end;
189-
return *this;
184+
bool IsSingleCid() const { return cid_start == cid_end; }
185+
bool Contains(intptr_t cid) { return cid_start <= cid && cid <= cid_end; }
186+
int32_t Extent() const { return cid_end - cid_start; }
187+
188+
// The number of class ids this range covers.
189+
intptr_t size() const { return cid_end - cid_start + 1; }
190+
191+
bool IsIllegalRange() const {
192+
return cid_start == kIllegalCid && cid_end == kIllegalCid;
190193
}
191194

195+
intptr_t cid_start;
196+
intptr_t cid_end;
197+
198+
DISALLOW_COPY_AND_ASSIGN(CidRange);
199+
};
200+
201+
struct CidRangeValue {
202+
CidRangeValue(intptr_t cid_start_arg, intptr_t cid_end_arg)
203+
: cid_start(cid_start_arg), cid_end(cid_end_arg) {}
204+
CidRangeValue(const CidRange& other) // NOLINT
205+
: cid_start(other.cid_start), cid_end(other.cid_end) {}
206+
192207
bool IsSingleCid() const { return cid_start == cid_end; }
193208
bool Contains(intptr_t cid) { return cid_start <= cid && cid <= cid_end; }
194209
int32_t Extent() const { return cid_end - cid_start; }
@@ -204,7 +219,7 @@ struct CidRange : public ZoneAllocated {
204219
intptr_t cid_end;
205220
};
206221

207-
typedef MallocGrowableArray<CidRange> CidRangeVector;
222+
typedef MallocGrowableArray<CidRangeValue> CidRangeVector;
208223

209224
class HierarchyInfo : public ThreadStackResource {
210225
public:
@@ -576,6 +591,8 @@ struct TargetInfo : public CidRange {
576591
const Function* target;
577592
intptr_t count;
578593
StaticTypeExactnessState exactness;
594+
595+
DISALLOW_COPY_AND_ASSIGN(TargetInfo);
579596
};
580597

581598
// A set of class-ids, arranged in ranges. Used for the CheckClass
@@ -3716,7 +3733,7 @@ class InstanceCallInstr : public TemplateDartCall<0> {
37163733
const CallTargets& Targets();
37173734
void SetTargets(const CallTargets* targets) { targets_ = targets; }
37183735

3719-
const BinaryFeedback& BinaryFeedback();
3736+
const class BinaryFeedback& BinaryFeedback();
37203737
void SetBinaryFeedback(const class BinaryFeedback* binary) {
37213738
binary_ = binary;
37223739
}
@@ -4248,7 +4265,7 @@ class StaticCallInstr : public TemplateDartCall<0> {
42484265
virtual void SetIdentity(AliasIdentity identity) { identity_ = identity; }
42494266

42504267
const CallTargets& Targets();
4251-
const BinaryFeedback& BinaryFeedback();
4268+
const class BinaryFeedback& BinaryFeedback();
42524269

42534270
PRINT_OPERANDS_TO_SUPPORT
42544271
ADD_OPERANDS_TO_S_EXPRESSION_SUPPORT
@@ -7810,13 +7827,13 @@ class CheckNullInstr : public TemplateDefinition<1, Throws, Pure> {
78107827

78117828
class CheckClassIdInstr : public TemplateInstruction<1, NoThrow> {
78127829
public:
7813-
CheckClassIdInstr(Value* value, CidRange cids, intptr_t deopt_id)
7830+
CheckClassIdInstr(Value* value, CidRangeValue cids, intptr_t deopt_id)
78147831
: TemplateInstruction(deopt_id), cids_(cids) {
78157832
SetInputAt(0, value);
78167833
}
78177834

78187835
Value* value() const { return inputs_[0]; }
7819-
const CidRange& cids() const { return cids_; }
7836+
const CidRangeValue& cids() const { return cids_; }
78207837

78217838
DECLARE_INSTRUCTION(CheckClassId)
78227839

@@ -7834,7 +7851,7 @@ class CheckClassIdInstr : public TemplateInstruction<1, NoThrow> {
78347851
private:
78357852
bool Contains(intptr_t cid) const;
78367853

7837-
CidRange cids_;
7854+
CidRangeValue cids_;
78387855

78397856
DISALLOW_COPY_AND_ASSIGN(CheckClassIdInstr);
78407857
};

runtime/vm/compiler/backend/il_deserializer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ bool FlowGraphDeserializer::ParseType(SExpression* sexp, Object* out) {
17681768
// This isn't necessary the hash value we will have in the new FlowGraph, but
17691769
// it will be how this type is referred to by TypeRefs in the serialized one.
17701770
auto const old_hash = is_recursive ? hash_sexp->value() : 0;
1771-
ZoneGrowableArray<TypeRef*>* pending_typerefs;
1771+
ZoneGrowableArray<TypeRef*>* pending_typerefs = nullptr;
17721772
if (is_recursive) {
17731773
if (pending_typeref_map_.LookupValue(old_hash) != nullptr) {
17741774
StoreError(sexp, "already parsing a type with hash %" Pd64 "",

0 commit comments

Comments
 (0)