Commit ab98dcc9 authored by avi's avatar avi Committed by Commit bot

Switch to standard integer types in courgette/.

BUG=138542
TBR=wfh@chromium.org
NOPRESUBMIT=true

Review URL: https://codereview.chromium.org/1543643002

Cr-Commit-Position: refs/heads/master@{#366439}
parent 34318488
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "courgette/adjustment_method.h" #include "courgette/adjustment_method.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm> #include <algorithm>
#include <list> #include <list>
#include <map> #include <map>
...@@ -11,8 +14,8 @@ ...@@ -11,8 +14,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/basictypes.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "courgette/assembly_program.h" #include "courgette/assembly_program.h"
...@@ -41,10 +44,10 @@ class LabelInfo { ...@@ -41,10 +44,10 @@ class LabelInfo {
Label* label_; // The label that this info a surrogate for. Label* label_; // The label that this info a surrogate for.
// Information used only in debugging messages. // Information used only in debugging messages.
uint32 is_model_ : 1; // Is the label in the model? uint32_t is_model_ : 1; // Is the label in the model?
uint32 debug_index_ : 31; // An unique small number for naming the label. uint32_t debug_index_ : 31; // An unique small number for naming the label.
uint32 refs_; // Number of times this Label is referenced. uint32_t refs_; // Number of times this Label is referenced.
LabelInfo* assignment_; // Label from other program corresponding to this. LabelInfo* assignment_; // Label from other program corresponding to this.
...@@ -53,7 +56,7 @@ class LabelInfo { ...@@ -53,7 +56,7 @@ class LabelInfo {
LabelInfo* next_addr_; // Label(Info) at next highest address. LabelInfo* next_addr_; // Label(Info) at next highest address.
LabelInfo* prev_addr_; // Label(Info) at next lowest address. LabelInfo* prev_addr_; // Label(Info) at next lowest address.
std::vector<uint32> positions_; // Offsets into the trace of references. std::vector<uint32_t> positions_; // Offsets into the trace of references.
// Just a no-argument constructor and copy constructor. Actual LabelInfo // Just a no-argument constructor and copy constructor. Actual LabelInfo
// objects are allocated in std::pair structs in a std::map. // objects are allocated in std::pair structs in a std::map.
...@@ -149,9 +152,7 @@ struct Node { ...@@ -149,9 +152,7 @@ struct Node {
bool in_queue_; bool in_queue_;
bool Extended() const { return !edges_.empty(); } bool Extended() const { return !edges_.empty(); }
uint32 Weight() const { uint32_t Weight() const { return edges_in_frequency_order.front()->count_; }
return edges_in_frequency_order.front()->count_;
}
}; };
static std::string ToString(Node* node) { static std::string ToString(Node* node) {
...@@ -190,8 +191,8 @@ struct OrderNodeByWeightDecreasing { ...@@ -190,8 +191,8 @@ struct OrderNodeByWeightDecreasing {
bool operator()(Node* a, Node* b) const { bool operator()(Node* a, Node* b) const {
// (Maybe tie-break on total count, followed by lowest assigned node indexes // (Maybe tie-break on total count, followed by lowest assigned node indexes
// in path.) // in path.)
uint32 a_weight = a->Weight(); uint32_t a_weight = a->Weight();
uint32 b_weight = b->Weight(); uint32_t b_weight = b->Weight();
if (a_weight != b_weight) if (a_weight != b_weight)
return a_weight > b_weight; return a_weight > b_weight;
if (a->length_ != b->length_) if (a->length_ != b->length_)
...@@ -254,7 +255,7 @@ class AssignmentProblem { ...@@ -254,7 +255,7 @@ class AssignmentProblem {
void SkipCommittedLabels(Node* node) { void SkipCommittedLabels(Node* node) {
ExtendNode(node, p_trace_); ExtendNode(node, p_trace_);
uint32 skipped = 0; uint32_t skipped = 0;
while (!node->edges_in_frequency_order.empty() && while (!node->edges_in_frequency_order.empty() &&
node->edges_in_frequency_order.front()->in_edge_->assignment_) { node->edges_in_frequency_order.front()->in_edge_->assignment_) {
++skipped; ++skipped;
...@@ -421,9 +422,9 @@ class AssignmentProblem { ...@@ -421,9 +422,9 @@ class AssignmentProblem {
} }
} }
uint32 TryExtendSequence(uint32 p_pos_start, uint32 m_pos_start) { uint32_t TryExtendSequence(uint32_t p_pos_start, uint32_t m_pos_start) {
uint32 p_pos = p_pos_start + 1; uint32_t p_pos = p_pos_start + 1;
uint32 m_pos = m_pos_start + 1; uint32_t m_pos = m_pos_start + 1;
while (p_pos < p_trace_.size() && m_pos < m_trace_.size()) { while (p_pos < p_trace_.size() && m_pos < m_trace_.size()) {
LabelInfo* p_info = p_trace_[p_pos]; LabelInfo* p_info = p_trace_[p_pos];
...@@ -456,12 +457,13 @@ class AssignmentProblem { ...@@ -456,12 +457,13 @@ class AssignmentProblem {
return p_pos - p_pos_start; return p_pos - p_pos_start;
} }
uint32 TryExtendSequenceBackwards(uint32 p_pos_start, uint32 m_pos_start) { uint32_t TryExtendSequenceBackwards(uint32_t p_pos_start,
uint32_t m_pos_start) {
if (p_pos_start == 0 || m_pos_start == 0) if (p_pos_start == 0 || m_pos_start == 0)
return 0; return 0;
uint32 p_pos = p_pos_start - 1; uint32_t p_pos = p_pos_start - 1;
uint32 m_pos = m_pos_start - 1; uint32_t m_pos = m_pos_start - 1;
while (p_pos > 0 && m_pos > 0) { while (p_pos > 0 && m_pos > 0) {
LabelInfo* p_info = p_trace_[p_pos]; LabelInfo* p_info = p_trace_[p_pos];
...@@ -522,7 +524,7 @@ class AssignmentProblem { ...@@ -522,7 +524,7 @@ class AssignmentProblem {
Node* MakeRootNode(const Trace& trace) { Node* MakeRootNode(const Trace& trace) {
Node* node = new Node(NULL, NULL); Node* node = new Node(NULL, NULL);
all_nodes_.push_back(node); all_nodes_.push_back(node);
for (uint32 i = 0; i < trace.size(); ++i) { for (uint32_t i = 0; i < trace.size(); ++i) {
++node->count_; ++node->count_;
node->places_.push_back(i); node->places_.push_back(i);
} }
...@@ -534,7 +536,7 @@ class AssignmentProblem { ...@@ -534,7 +536,7 @@ class AssignmentProblem {
if (node->Extended()) if (node->Extended())
return; return;
for (size_t i = 0; i < node->places_.size(); ++i) { for (size_t i = 0; i < node->places_.size(); ++i) {
uint32 index = node->places_.at(i); uint32_t index = node->places_.at(i);
if (index < trace.size()) { if (index < trace.size()) {
LabelInfo* item = trace.at(index); LabelInfo* item = trace.at(index);
Node*& slot = node->edges_[item]; Node*& slot = node->edges_[item];
...@@ -633,11 +635,11 @@ class GraphAdjuster : public AdjustmentMethod { ...@@ -633,11 +635,11 @@ class GraphAdjuster : public AdjustmentMethod {
} }
void ReferenceLabel(Trace* trace, Label* label, bool is_model) { void ReferenceLabel(Trace* trace, Label* label, bool is_model) {
trace->push_back(MakeLabelInfo(label, is_model, trace->push_back(
static_cast<uint32>(trace->size()))); MakeLabelInfo(label, is_model, static_cast<uint32_t>(trace->size())));
} }
LabelInfo* MakeLabelInfo(Label* label, bool is_model, uint32 position) { LabelInfo* MakeLabelInfo(Label* label, bool is_model, uint32_t position) {
LabelInfo& slot = label_infos_[label]; LabelInfo& slot = label_infos_[label];
if (slot.label_ == NULL) { if (slot.label_ == NULL) {
slot.label_ = label; slot.label_ = label;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef COURGETTE_ADJUSTMENT_METHOD_H_ #ifndef COURGETTE_ADJUSTMENT_METHOD_H_
#define COURGETTE_ADJUSTMENT_METHOD_H_ #define COURGETTE_ADJUSTMENT_METHOD_H_
#include "base/basictypes.h" #include "base/macros.h"
namespace courgette { namespace courgette {
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "courgette/adjustment_method.h" #include "courgette/adjustment_method.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
#include <list> #include <list>
...@@ -12,9 +15,9 @@ ...@@ -12,9 +15,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/basictypes.h"
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "courgette/assembly_program.h" #include "courgette/assembly_program.h"
...@@ -176,16 +179,16 @@ class LabelInfo { ...@@ -176,16 +179,16 @@ class LabelInfo {
Label* label_; // The label that this info a surrogate for. Label* label_; // The label that this info a surrogate for.
uint32 is_model_ : 1; // Is the label in the model? uint32_t is_model_ : 1; // Is the label in the model?
uint32 debug_index_ : 31; // A small number for naming the label in debug uint32_t debug_index_ : 31; // A small number for naming the label in debug
// output. The pair (is_model_, debug_index_) is // output. The pair (is_model_, debug_index_) is
// unique. // unique.
int refs_; // Number of times this Label is referenced. int refs_; // Number of times this Label is referenced.
LabelInfo* assignment_; // Label from other program corresponding to this. LabelInfo* assignment_; // Label from other program corresponding to this.
std::vector<uint32> positions_; // Offsets into the trace of references. std::vector<uint32_t> positions_; // Offsets into the trace of references.
private: private:
AssignmentCandidates* candidates_; AssignmentCandidates* candidates_;
...@@ -213,7 +216,7 @@ class LabelInfoMaker { ...@@ -213,7 +216,7 @@ class LabelInfoMaker {
public: public:
LabelInfoMaker() : debug_label_index_gen_(0) {} LabelInfoMaker() : debug_label_index_gen_(0) {}
LabelInfo* MakeLabelInfo(Label* label, bool is_model, uint32 position) { LabelInfo* MakeLabelInfo(Label* label, bool is_model, uint32_t position) {
LabelInfo& slot = label_infos_[label]; LabelInfo& slot = label_infos_[label];
if (slot.label_ == NULL) { if (slot.label_ == NULL) {
slot.label_ = label; slot.label_ = label;
...@@ -364,7 +367,7 @@ LabelInfo::~LabelInfo() { ...@@ -364,7 +367,7 @@ LabelInfo::~LabelInfo() {
// position of one of the occurrences in the Trace. // position of one of the occurrences in the Trace.
class Shingle { class Shingle {
public: public:
static const uint8 kWidth = 5; static const uint8_t kWidth = 5;
struct InterningLess { struct InterningLess {
bool operator()(const Shingle& a, const Shingle& b) const; bool operator()(const Shingle& a, const Shingle& b) const;
...@@ -388,7 +391,7 @@ class Shingle { ...@@ -388,7 +391,7 @@ class Shingle {
LabelInfo* at(size_t i) const { return trace_[exemplar_position_ + i]; } LabelInfo* at(size_t i) const { return trace_[exemplar_position_ + i]; }
void add_position(size_t position) { void add_position(size_t position) {
positions_.push_back(static_cast<uint32>(position)); positions_.push_back(static_cast<uint32_t>(position));
} }
int position_count() const { return static_cast<int>(positions_.size()); } int position_count() const { return static_cast<int>(positions_.size()); }
...@@ -414,7 +417,7 @@ class Shingle { ...@@ -414,7 +417,7 @@ class Shingle {
const Trace& trace_; // The shingle lives inside trace_. const Trace& trace_; // The shingle lives inside trace_.
size_t exemplar_position_; // At this position (and other positions). size_t exemplar_position_; // At this position (and other positions).
std::vector<uint32> positions_; // Includes exemplar_position_. std::vector<uint32_t> positions_; // Includes exemplar_position_.
ShinglePattern* pattern_; // Pattern changes as LabelInfos are assigned. ShinglePattern* pattern_; // Pattern changes as LabelInfos are assigned.
...@@ -430,7 +433,7 @@ class Shingle { ...@@ -430,7 +433,7 @@ class Shingle {
std::string ToString(const Shingle* instance) { std::string ToString(const Shingle* instance) {
std::string s; std::string s;
const char* sep = "<"; const char* sep = "<";
for (uint8 i = 0; i < Shingle::kWidth; ++i) { for (uint8_t i = 0; i < Shingle::kWidth; ++i) {
// base::StringAppendF(&s, "%s%x ", sep, instance.at(i)->label_->rva_); // base::StringAppendF(&s, "%s%x ", sep, instance.at(i)->label_->rva_);
s += sep; s += sep;
s += ToString(instance->at(i)); s += ToString(instance->at(i));
...@@ -446,7 +449,7 @@ std::string ToString(const Shingle* instance) { ...@@ -446,7 +449,7 @@ std::string ToString(const Shingle* instance) {
bool Shingle::InterningLess::operator()( bool Shingle::InterningLess::operator()(
const Shingle& a, const Shingle& a,
const Shingle& b) const { const Shingle& b) const {
for (uint8 i = 0; i < kWidth; ++i) { for (uint8_t i = 0; i < kWidth; ++i) {
LabelInfo* info_a = a.at(i); LabelInfo* info_a = a.at(i);
LabelInfo* info_b = b.at(i); LabelInfo* info_b = b.at(i);
if (info_a->label_->rva_ < info_b->label_->rva_) if (info_a->label_->rva_ < info_b->label_->rva_)
...@@ -478,11 +481,11 @@ class ShinglePattern { ...@@ -478,11 +481,11 @@ class ShinglePattern {
// --> <kFixed+0, kVariable+1, kFixed+2, kVariable+1, kFixed+0> // --> <kFixed+0, kVariable+1, kFixed+2, kVariable+1, kFixed+0>
struct Index { struct Index {
explicit Index(const Shingle* instance); explicit Index(const Shingle* instance);
uint8 kinds_[Shingle::kWidth]; uint8_t kinds_[Shingle::kWidth];
uint8 variables_; uint8_t variables_;
uint8 unique_variables_; uint8_t unique_variables_;
uint8 first_variable_index_; uint8_t first_variable_index_;
uint32 hash_; uint32_t hash_;
int assigned_indexes_[Shingle::kWidth]; int assigned_indexes_[Shingle::kWidth];
}; };
...@@ -526,10 +529,10 @@ std::string ToString(const ShinglePattern::Index* index) { ...@@ -526,10 +529,10 @@ std::string ToString(const ShinglePattern::Index* index) {
} else { } else {
base::StringAppendF(&s, "<%d: ", index->variables_); base::StringAppendF(&s, "<%d: ", index->variables_);
const char* sep = ""; const char* sep = "";
for (uint8 i = 0; i < Shingle::kWidth; ++i) { for (uint8_t i = 0; i < Shingle::kWidth; ++i) {
s += sep; s += sep;
sep = ", "; sep = ", ";
uint32 kind = index->kinds_[i]; uint32_t kind = index->kinds_[i];
int offset = kind & ShinglePattern::kOffsetMask; int offset = kind & ShinglePattern::kOffsetMask;
if (kind & ShinglePattern::kVariable) if (kind & ShinglePattern::kVariable)
base::StringAppendF(&s, "V%d", offset); base::StringAppendF(&s, "V%d", offset);
...@@ -622,7 +625,7 @@ struct ShinglePatternIndexLess { ...@@ -622,7 +625,7 @@ struct ShinglePatternIndexLess {
if (a.hash_ < b.hash_) return true; if (a.hash_ < b.hash_) return true;
if (a.hash_ > b.hash_) return false; if (a.hash_ > b.hash_) return false;
for (uint8 i = 0; i < Shingle::kWidth; ++i) { for (uint8_t i = 0; i < Shingle::kWidth; ++i) {
if (a.kinds_[i] < b.kinds_[i]) return true; if (a.kinds_[i] < b.kinds_[i]) return true;
if (a.kinds_[i] > b.kinds_[i]) return false; if (a.kinds_[i] > b.kinds_[i]) return false;
if ((a.kinds_[i] & ShinglePattern::kVariable) == 0) { if ((a.kinds_[i] & ShinglePattern::kVariable) == 0) {
...@@ -636,22 +639,22 @@ struct ShinglePatternIndexLess { ...@@ -636,22 +639,22 @@ struct ShinglePatternIndexLess {
} }
}; };
static uint32 hash_combine(uint32 h, uint32 v) { static uint32_t hash_combine(uint32_t h, uint32_t v) {
h += v; h += v;
return (h * (37 + 0x0000d100)) ^ (h >> 13); return (h * (37 + 0x0000d100)) ^ (h >> 13);
} }
ShinglePattern::Index::Index(const Shingle* instance) { ShinglePattern::Index::Index(const Shingle* instance) {
uint32 hash = 0; uint32_t hash = 0;
variables_ = 0; variables_ = 0;
unique_variables_ = 0; unique_variables_ = 0;
first_variable_index_ = 255; first_variable_index_ = 255;
for (uint8 i = 0; i < Shingle::kWidth; ++i) { for (uint8_t i = 0; i < Shingle::kWidth; ++i) {
LabelInfo* info = instance->at(i); LabelInfo* info = instance->at(i);
uint8 kind = 0; uint8_t kind = 0;
int code = -1; int code = -1;
uint8 j = 0; uint8_t j = 0;
for ( ; j < i; ++j) { for ( ; j < i; ++j) {
if (info == instance->at(j)) { // Duplicate LabelInfo if (info == instance->at(j)) { // Duplicate LabelInfo
kind = kinds_[j]; kind = kinds_[j];
...@@ -942,7 +945,7 @@ class AssignmentProblem { ...@@ -942,7 +945,7 @@ class AssignmentProblem {
// For the positions in |info|, find the shingles that overlap that position. // For the positions in |info|, find the shingles that overlap that position.
void AddAffectedPositions(LabelInfo* info, ShingleSet* affected_shingles) { void AddAffectedPositions(LabelInfo* info, ShingleSet* affected_shingles) {
const uint8 kWidth = Shingle::kWidth; const uint8_t kWidth = Shingle::kWidth;
for (size_t i = 0; i < info->positions_.size(); ++i) { for (size_t i = 0; i < info->positions_.size(); ++i) {
size_t position = info->positions_[i]; size_t position = info->positions_[i];
// Find bounds to the subrange of |trace_| we are in. // Find bounds to the subrange of |trace_| we are in.
...@@ -1059,7 +1062,7 @@ class AssignmentProblem { ...@@ -1059,7 +1062,7 @@ class AssignmentProblem {
// int score = p1; // ? weigh all equally?? // int score = p1; // ? weigh all equally??
int score = std::min(p1, m1); int score = std::min(p1, m1);
for (uint8 i = 0; i < Shingle::kWidth; ++i) { for (uint8_t i = 0; i < Shingle::kWidth; ++i) {
LabelInfo* program_info = program_instance->at(i); LabelInfo* program_info = program_instance->at(i);
LabelInfo* model_info = model_instance->at(i); LabelInfo* model_info = model_instance->at(i);
if ((model_info->assignment_ == NULL) != if ((model_info->assignment_ == NULL) !=
...@@ -1275,9 +1278,8 @@ class Adjuster : public AdjustmentMethod { ...@@ -1275,9 +1278,8 @@ class Adjuster : public AdjustmentMethod {
} }
void ReferenceLabel(Trace* trace, Label* label, bool is_model) { void ReferenceLabel(Trace* trace, Label* label, bool is_model) {
trace->push_back( trace->push_back(label_info_maker_.MakeLabelInfo(
label_info_maker_.MakeLabelInfo(label, is_model, label, is_model, static_cast<uint32_t>(trace->size())));
static_cast<uint32>(trace->size())));
} }
AssemblyProgram* prog_; // Program to be adjusted, owned by caller. AssemblyProgram* prog_; // Program to be adjusted, owned by caller.
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "courgette/assembly_program.h" #include "courgette/assembly_program.h"
#include <memory.h> #include <memory.h>
#include <stddef.h>
#include <stdint.h>
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <set> #include <set>
...@@ -52,22 +54,20 @@ class ElfARMRelocsInstruction : public Instruction { ...@@ -52,22 +54,20 @@ class ElfARMRelocsInstruction : public Instruction {
// Emits a single byte. // Emits a single byte.
class ByteInstruction : public Instruction { class ByteInstruction : public Instruction {
public: public:
explicit ByteInstruction(uint8 value) : Instruction(DEFBYTE, value) {} explicit ByteInstruction(uint8_t value) : Instruction(DEFBYTE, value) {}
uint8 byte_value() const { return info_; } uint8_t byte_value() const { return info_; }
}; };
// Emits a single byte. // Emits a single byte.
class BytesInstruction : public Instruction { class BytesInstruction : public Instruction {
public: public:
BytesInstruction(const uint8* values, size_t len) BytesInstruction(const uint8_t* values, size_t len)
: Instruction(DEFBYTES, 0), : Instruction(DEFBYTES, 0), values_(values), len_(len) {}
values_(values), const uint8_t* byte_values() const { return values_; }
len_(len) {}
const uint8* byte_values() const { return values_; }
size_t len() const { return len_; } size_t len() const { return len_; }
private: private:
const uint8* values_; const uint8_t* values_;
size_t len_; size_t len_;
}; };
...@@ -87,19 +87,25 @@ class InstructionWithLabel : public Instruction { ...@@ -87,19 +87,25 @@ class InstructionWithLabel : public Instruction {
// a specially-compressed ARM op. // a specially-compressed ARM op.
class InstructionWithLabelARM : public InstructionWithLabel { class InstructionWithLabelARM : public InstructionWithLabel {
public: public:
InstructionWithLabelARM(OP op, uint16 compressed_op, Label* label, InstructionWithLabelARM(OP op,
const uint8* arm_op, uint16 op_size) uint16_t compressed_op,
: InstructionWithLabel(op, label), compressed_op_(compressed_op), Label* label,
arm_op_(arm_op), op_size_(op_size) { const uint8_t* arm_op,
uint16_t op_size)
: InstructionWithLabel(op, label),
compressed_op_(compressed_op),
arm_op_(arm_op),
op_size_(op_size) {
if (label == NULL) NOTREACHED(); if (label == NULL) NOTREACHED();
} }
uint16 compressed_op() const { return compressed_op_; } uint16_t compressed_op() const { return compressed_op_; }
const uint8* arm_op() const { return arm_op_; } const uint8_t* arm_op() const { return arm_op_; }
uint16 op_size() const { return op_size_; } uint16_t op_size() const { return op_size_; }
private: private:
uint16 compressed_op_; uint16_t compressed_op_;
const uint8* arm_op_; const uint8_t* arm_op_;
uint16 op_size_; uint16_t op_size_;
}; };
} // namespace } // namespace
...@@ -143,11 +149,11 @@ CheckBool AssemblyProgram::EmitOriginInstruction(RVA rva) { ...@@ -143,11 +149,11 @@ CheckBool AssemblyProgram::EmitOriginInstruction(RVA rva) {
return Emit(ScopedInstruction(UncheckedNew<OriginInstruction>(rva))); return Emit(ScopedInstruction(UncheckedNew<OriginInstruction>(rva)));
} }
CheckBool AssemblyProgram::EmitByteInstruction(uint8 byte) { CheckBool AssemblyProgram::EmitByteInstruction(uint8_t byte) {
return EmitShared(GetByteInstruction(byte)); return EmitShared(GetByteInstruction(byte));
} }
CheckBool AssemblyProgram::EmitBytesInstruction(const uint8* values, CheckBool AssemblyProgram::EmitBytesInstruction(const uint8_t* values,
size_t len) { size_t len) {
return Emit(ScopedInstruction(UncheckedNew<BytesInstruction>(values, len))); return Emit(ScopedInstruction(UncheckedNew<BytesInstruction>(values, len)));
} }
...@@ -157,8 +163,10 @@ CheckBool AssemblyProgram::EmitRel32(Label* label) { ...@@ -157,8 +163,10 @@ CheckBool AssemblyProgram::EmitRel32(Label* label) {
ScopedInstruction(UncheckedNew<InstructionWithLabel>(REL32, label))); ScopedInstruction(UncheckedNew<InstructionWithLabel>(REL32, label)));
} }
CheckBool AssemblyProgram::EmitRel32ARM(uint16 op, Label* label, CheckBool AssemblyProgram::EmitRel32ARM(uint16_t op,
const uint8* arm_op, uint16 op_size) { Label* label,
const uint8_t* arm_op,
uint16_t op_size) {
return Emit(ScopedInstruction(UncheckedNew<InstructionWithLabelARM>( return Emit(ScopedInstruction(UncheckedNew<InstructionWithLabelARM>(
REL32ARM, op, label, arm_op, op_size))); REL32ARM, op, label, arm_op, op_size)));
} }
...@@ -324,7 +332,7 @@ void AssemblyProgram::AssignRemainingIndexes(RVAToLabel* labels) { ...@@ -324,7 +332,7 @@ void AssemblyProgram::AssignRemainingIndexes(RVAToLabel* labels) {
if (prev) if (prev)
prev_index = prev->index_; prev_index = prev->index_;
else else
prev_index = static_cast<uint32>(available.size()); prev_index = static_cast<uint32_t>(available.size());
if (prev_index != 0 && if (prev_index != 0 &&
prev_index != Label::kNoIndex && prev_index != Label::kNoIndex &&
available.at(prev_index - 1)) { available.at(prev_index - 1)) {
...@@ -400,14 +408,14 @@ EncodedProgram* AssemblyProgram::Encode() const { ...@@ -400,14 +408,14 @@ EncodedProgram* AssemblyProgram::Encode() const {
break; break;
} }
case DEFBYTE: { case DEFBYTE: {
uint8 b = static_cast<ByteInstruction*>(instruction)->byte_value(); uint8_t b = static_cast<ByteInstruction*>(instruction)->byte_value();
if (!encoded->AddCopy(1, &b)) if (!encoded->AddCopy(1, &b))
return NULL; return NULL;
break; break;
} }
case DEFBYTES: { case DEFBYTES: {
const uint8* byte_values = const uint8_t* byte_values =
static_cast<BytesInstruction*>(instruction)->byte_values(); static_cast<BytesInstruction*>(instruction)->byte_values();
size_t len = static_cast<BytesInstruction*>(instruction)->len(); size_t len = static_cast<BytesInstruction*>(instruction)->len();
if (!encoded->AddCopy(len, byte_values)) if (!encoded->AddCopy(len, byte_values))
...@@ -423,9 +431,8 @@ EncodedProgram* AssemblyProgram::Encode() const { ...@@ -423,9 +431,8 @@ EncodedProgram* AssemblyProgram::Encode() const {
case REL32ARM: { case REL32ARM: {
Label* label = Label* label =
static_cast<InstructionWithLabelARM*>(instruction)->label(); static_cast<InstructionWithLabelARM*>(instruction)->label();
uint16 compressed_op = uint16_t compressed_op =
static_cast<InstructionWithLabelARM*>(instruction)-> static_cast<InstructionWithLabelARM*>(instruction)->compressed_op();
compressed_op();
if (!encoded->AddRel32ARM(compressed_op, label->index_)) if (!encoded->AddRel32ARM(compressed_op, label->index_))
return NULL; return NULL;
break; break;
...@@ -466,7 +473,7 @@ EncodedProgram* AssemblyProgram::Encode() const { ...@@ -466,7 +473,7 @@ EncodedProgram* AssemblyProgram::Encode() const {
return encoded.release(); return encoded.release();
} }
Instruction* AssemblyProgram::GetByteInstruction(uint8 byte) { Instruction* AssemblyProgram::GetByteInstruction(uint8_t byte) {
if (!byte_instruction_cache_) { if (!byte_instruction_cache_) {
Instruction** ram = nullptr; Instruction** ram = nullptr;
if (!base::UncheckedMalloc(sizeof(Instruction*) * 256, if (!base::UncheckedMalloc(sizeof(Instruction*) * 256,
...@@ -477,7 +484,7 @@ Instruction* AssemblyProgram::GetByteInstruction(uint8 byte) { ...@@ -477,7 +484,7 @@ Instruction* AssemblyProgram::GetByteInstruction(uint8 byte) {