Skip to content

Commit cbcb7fb

Browse files
committed
Merge branch 'v8-3.1' into v0.4
2 parents 53bec1c + c8ee19a commit cbcb7fb

14 files changed

+235
-48
lines changed

deps/v8/SConstruct

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ V8_EXTRA_FLAGS = {
306306
'gcc': {
307307
'all': {
308308
'WARNINGFLAGS': ['-Wall',
309+
'-Werror',
309310
'-W',
310311
'-Wno-unused-parameter',
311312
'-Wnon-virtual-dtor']

deps/v8/src/arm/deoptimizer-arm.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ int Deoptimizer::patch_size() {
4444
}
4545

4646

47+
void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) {
48+
// Nothing to do. No new relocation information is written for lazy
49+
// deoptimization on ARM.
50+
}
51+
4752

4853
void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
4954
AssertNoAllocation no_allocation;

deps/v8/src/arm/lithium-codegen-arm.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void LCodeGen::FinishCode(Handle<Code> code) {
7575
code->set_stack_slots(StackSlotCount());
7676
code->set_safepoint_table_offset(safepoints_.GetCodeOffset());
7777
PopulateDeoptimizationData(code);
78+
Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code);
7879
}
7980

8081

deps/v8/src/assembler.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const int kPCJumpTag = (1 << kExtraTagBits) - 1;
139139

140140
const int kSmallPCDeltaBits = kBitsPerByte - kTagBits;
141141
const int kSmallPCDeltaMask = (1 << kSmallPCDeltaBits) - 1;
142+
const int RelocInfo::kMaxSmallPCDelta = kSmallPCDeltaMask;
142143

143144
const int kVariableLengthPCJumpTopTag = 1;
144145
const int kChunkBits = 7;

deps/v8/src/assembler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ class RelocInfo BASE_EMBEDDED {
192192
// The maximum size for a call instruction including pc-jump.
193193
static const int kMaxCallSize = 6;
194194

195+
// The maximum pc delta that will use the short encoding.
196+
static const int kMaxSmallPCDelta;
197+
195198
enum Mode {
196199
// Please note the order is important (see IsCodeTarget, IsGCRelocMode).
197200
CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor.

deps/v8/src/deoptimizer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ class Deoptimizer : public Malloced {
110110
int fp_to_sp_delta);
111111
static Deoptimizer* Grab();
112112

113+
// Makes sure that there is enough room in the relocation
114+
// information of a code object to perform lazy deoptimization
115+
// patching. If there is not enough room a new relocation
116+
// information object is allocated and comments are added until it
117+
// is big enough.
118+
static void EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code);
119+
113120
// Deoptimize the function now. Its current optimized code will never be run
114121
// again and any activations of the optimized code will get deoptimized when
115122
// execution returns.

deps/v8/src/hydrogen-instructions.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,8 +1423,9 @@ class HJSArrayLength: public HUnaryOperation {
14231423
// object. It is guaranteed to be 32 bit integer, but it can be
14241424
// represented as either a smi or heap number.
14251425
set_representation(Representation::Tagged());
1426-
SetFlag(kDependsOnArrayLengths);
14271426
SetFlag(kUseGVN);
1427+
SetFlag(kDependsOnArrayLengths);
1428+
SetFlag(kDependsOnMaps);
14281429
}
14291430

14301431
virtual Representation RequiredInputRepresentation(int index) const {
@@ -1442,8 +1443,8 @@ class HFixedArrayLength: public HUnaryOperation {
14421443
public:
14431444
explicit HFixedArrayLength(HValue* value) : HUnaryOperation(value) {
14441445
set_representation(Representation::Tagged());
1445-
SetFlag(kDependsOnArrayLengths);
14461446
SetFlag(kUseGVN);
1447+
SetFlag(kDependsOnArrayLengths);
14471448
}
14481449

14491450
virtual Representation RequiredInputRepresentation(int index) const {
@@ -2268,6 +2269,7 @@ class HCompareJSObjectEq: public HBinaryOperation {
22682269
: HBinaryOperation(left, right) {
22692270
set_representation(Representation::Tagged());
22702271
SetFlag(kUseGVN);
2272+
SetFlag(kDependsOnMaps);
22712273
}
22722274

22732275
virtual bool EmitAtUses() const {
@@ -2943,6 +2945,7 @@ class HLoadNamedField: public HUnaryOperation {
29432945
offset_(offset) {
29442946
set_representation(Representation::Tagged());
29452947
SetFlag(kUseGVN);
2948+
SetFlag(kDependsOnMaps);
29462949
if (is_in_object) {
29472950
SetFlag(kDependsOnInobjectFields);
29482951
} else {
@@ -3269,6 +3272,7 @@ class HStringCharCodeAt: public HBinaryOperation {
32693272
: HBinaryOperation(string, index) {
32703273
set_representation(Representation::Integer32());
32713274
SetFlag(kUseGVN);
3275+
SetFlag(kDependsOnMaps);
32723276
}
32733277

32743278
virtual Representation RequiredInputRepresentation(int index) const {
@@ -3296,6 +3300,7 @@ class HStringLength: public HUnaryOperation {
32963300
explicit HStringLength(HValue* string) : HUnaryOperation(string) {
32973301
set_representation(Representation::Tagged());
32983302
SetFlag(kUseGVN);
3303+
SetFlag(kDependsOnMaps);
32993304
}
33003305

33013306
virtual Representation RequiredInputRepresentation(int index) const {

deps/v8/src/ia32/deoptimizer-ia32.cc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,80 @@ static void ZapCodeRange(Address start, Address end) {
5555
}
5656

5757

58+
void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) {
59+
HandleScope scope;
60+
61+
// Compute the size of relocation information needed for the code
62+
// patching in Deoptimizer::DeoptimizeFunction.
63+
int min_reloc_size = 0;
64+
Address prev_reloc_address = code->instruction_start();
65+
Address code_start_address = code->instruction_start();
66+
SafepointTable table(*code);
67+
for (unsigned i = 0; i < table.length(); ++i) {
68+
Address curr_reloc_address = code_start_address + table.GetPcOffset(i);
69+
ASSERT_GE(curr_reloc_address, prev_reloc_address);
70+
SafepointEntry safepoint_entry = table.GetEntry(i);
71+
int deoptimization_index = safepoint_entry.deoptimization_index();
72+
if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) {
73+
// The gap code is needed to get to the state expected at the
74+
// bailout and we need to skip the call opcode to get to the
75+
// address that needs reloc.
76+
curr_reloc_address += safepoint_entry.gap_code_size() + 1;
77+
int pc_delta = curr_reloc_address - prev_reloc_address;
78+
// We use RUNTIME_ENTRY reloc info which has a size of 2 bytes
79+
// if encodable with small pc delta encoding and up to 6 bytes
80+
// otherwise.
81+
if (pc_delta <= RelocInfo::kMaxSmallPCDelta) {
82+
min_reloc_size += 2;
83+
} else {
84+
min_reloc_size += 6;
85+
}
86+
prev_reloc_address = curr_reloc_address;
87+
}
88+
}
89+
90+
// If the relocation information is not big enough we create a new
91+
// relocation info object that is padded with comments to make it
92+
// big enough for lazy doptimization.
93+
int reloc_length = code->relocation_info()->length();
94+
if (min_reloc_size > reloc_length) {
95+
int comment_reloc_size = RelocInfo::kMinRelocCommentSize;
96+
// Padding needed.
97+
int min_padding = min_reloc_size - reloc_length;
98+
// Number of comments needed to take up at least that much space.
99+
int additional_comments =
100+
(min_padding + comment_reloc_size - 1) / comment_reloc_size;
101+
// Actual padding size.
102+
int padding = additional_comments * comment_reloc_size;
103+
// Allocate new relocation info and copy old relocation to the end
104+
// of the new relocation info array because relocation info is
105+
// written and read backwards.
106+
Handle<ByteArray> new_reloc =
107+
Factory::NewByteArray(reloc_length + padding, TENURED);
108+
memcpy(new_reloc->GetDataStartAddress() + padding,
109+
code->relocation_info()->GetDataStartAddress(),
110+
reloc_length);
111+
// Create a relocation writer to write the comments in the padding
112+
// space. Use position 0 for everything to ensure short encoding.
113+
RelocInfoWriter reloc_info_writer(
114+
new_reloc->GetDataStartAddress() + padding, 0);
115+
intptr_t comment_string
116+
= reinterpret_cast<intptr_t>(RelocInfo::kFillerCommentString);
117+
RelocInfo rinfo(0, RelocInfo::COMMENT, comment_string);
118+
for (int i = 0; i < additional_comments; ++i) {
119+
#ifdef DEBUG
120+
byte* pos_before = reloc_info_writer.pos();
121+
#endif
122+
reloc_info_writer.Write(&rinfo);
123+
ASSERT(RelocInfo::kMinRelocCommentSize ==
124+
pos_before - reloc_info_writer.pos());
125+
}
126+
// Replace relocation information on the code object.
127+
code->set_relocation_info(*new_reloc);
128+
}
129+
}
130+
131+
58132
void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
59133
AssertNoAllocation no_allocation;
60134

deps/v8/src/ia32/lithium-codegen-ia32.cc

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "ia32/lithium-codegen-ia32.h"
3333
#include "code-stubs.h"
34+
#include "deoptimizer.h"
3435
#include "stub-cache.h"
3536

3637
namespace v8 {
@@ -43,28 +44,20 @@ class SafepointGenerator : public PostCallGenerator {
4344
public:
4445
SafepointGenerator(LCodeGen* codegen,
4546
LPointerMap* pointers,
46-
int deoptimization_index,
47-
bool ensure_reloc_space = false)
47+
int deoptimization_index)
4848
: codegen_(codegen),
4949
pointers_(pointers),
50-
deoptimization_index_(deoptimization_index),
51-
ensure_reloc_space_(ensure_reloc_space) { }
50+
deoptimization_index_(deoptimization_index) {}
5251
virtual ~SafepointGenerator() { }
5352

5453
virtual void Generate() {
55-
// Ensure that we have enough space in the reloc info to patch
56-
// this with calls when doing deoptimization.
57-
if (ensure_reloc_space_) {
58-
codegen_->EnsureRelocSpaceForDeoptimization();
59-
}
6054
codegen_->RecordSafepoint(pointers_, deoptimization_index_);
6155
}
6256

6357
private:
6458
LCodeGen* codegen_;
6559
LPointerMap* pointers_;
6660
int deoptimization_index_;
67-
bool ensure_reloc_space_;
6861
};
6962

7063

@@ -78,7 +71,6 @@ bool LCodeGen::GenerateCode() {
7871
return GeneratePrologue() &&
7972
GenerateBody() &&
8073
GenerateDeferredCode() &&
81-
GenerateRelocPadding() &&
8274
GenerateSafepointTable();
8375
}
8476

@@ -88,6 +80,7 @@ void LCodeGen::FinishCode(Handle<Code> code) {
8880
code->set_stack_slots(StackSlotCount());
8981
code->set_safepoint_table_offset(safepoints_.GetCodeOffset());
9082
PopulateDeoptimizationData(code);
83+
Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code);
9184
}
9285

9386

@@ -385,22 +378,6 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
385378
}
386379

387380

388-
void LCodeGen::EnsureRelocSpaceForDeoptimization() {
389-
// Since we patch the reloc info with RUNTIME_ENTRY calls every patch
390-
// site will take up 2 bytes + any pc-jumps.
391-
// We are conservative and always reserver 6 bytes in case where a
392-
// simple pc-jump is not enough.
393-
uint32_t pc_delta =
394-
masm()->pc_offset() - deoptimization_reloc_size.last_pc_offset;
395-
if (is_uintn(pc_delta, 6)) {
396-
deoptimization_reloc_size.min_size += 2;
397-
} else {
398-
deoptimization_reloc_size.min_size += 6;
399-
}
400-
deoptimization_reloc_size.last_pc_offset = masm()->pc_offset();
401-
}
402-
403-
404381
void LCodeGen::AddToTranslation(Translation* translation,
405382
LOperand* op,
406383
bool is_tagged) {
@@ -454,7 +431,6 @@ void LCodeGen::CallCode(Handle<Code> code,
454431
}
455432
__ call(code, mode);
456433

457-
EnsureRelocSpaceForDeoptimization();
458434
RegisterLazyDeoptimization(instr);
459435

460436
// Signal that we don't inline smi code before these stubs in the
@@ -479,6 +455,7 @@ void LCodeGen::CallRuntime(Runtime::Function* fun,
479455
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
480456
}
481457
__ CallRuntime(fun, argc);
458+
482459
RegisterLazyDeoptimization(instr);
483460
}
484461

@@ -2299,8 +2276,7 @@ void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
22992276
RegisterEnvironmentForDeoptimization(env);
23002277
SafepointGenerator safepoint_generator(this,
23012278
pointers,
2302-
env->deoptimization_index(),
2303-
true);
2279+
env->deoptimization_index());
23042280
v8::internal::ParameterCount actual(eax);
23052281
__ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator);
23062282
}
@@ -2372,7 +2348,6 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
23722348
__ CallSelf();
23732349
} else {
23742350
__ call(FieldOperand(edi, JSFunction::kCodeEntryOffset));
2375-
EnsureRelocSpaceForDeoptimization();
23762351
}
23772352

23782353
// Setup deoptimization.
@@ -3835,8 +3810,7 @@ void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) {
38353810
// builtin)
38363811
SafepointGenerator safepoint_generator(this,
38373812
pointers,
3838-
env->deoptimization_index(),
3839-
true);
3813+
env->deoptimization_index());
38403814
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
38413815
__ push(Immediate(Smi::FromInt(strict_mode_flag())));
38423816
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator);

deps/v8/src/version.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define MAJOR_VERSION 3
3636
#define MINOR_VERSION 1
3737
#define BUILD_NUMBER 8
38-
#define PATCH_LEVEL 3
38+
#define PATCH_LEVEL 5
3939
#define CANDIDATE_VERSION false
4040

4141
// Define SONAME to have the SCons build the put a specific SONAME into the

deps/v8/src/x64/deoptimizer-x64.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ class SafepointTableDeoptimiztionEntryIterator {
101101
};
102102

103103

104+
void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) {
105+
// TODO(1276): Implement.
106+
}
107+
108+
104109
void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
105110
AssertNoAllocation no_allocation;
106111

deps/v8/src/x64/lithium-codegen-x64.cc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,23 @@ class SafepointGenerator : public PostCallGenerator {
4343
public:
4444
SafepointGenerator(LCodeGen* codegen,
4545
LPointerMap* pointers,
46-
int deoptimization_index,
47-
bool ensure_reloc_space = false)
46+
int deoptimization_index)
4847
: codegen_(codegen),
4948
pointers_(pointers),
50-
deoptimization_index_(deoptimization_index),
51-
ensure_reloc_space_(ensure_reloc_space) { }
49+
deoptimization_index_(deoptimization_index) { }
5250
virtual ~SafepointGenerator() { }
5351

5452
virtual void Generate() {
5553
// Ensure that we have enough space in the reloc info to patch
5654
// this with calls when doing deoptimization.
57-
if (ensure_reloc_space_) {
58-
codegen_->masm()->RecordComment(RelocInfo::kFillerCommentString, true);
59-
}
55+
codegen_->masm()->RecordComment(RelocInfo::kFillerCommentString, true);
6056
codegen_->RecordSafepoint(pointers_, deoptimization_index_);
6157
}
6258

6359
private:
6460
LCodeGen* codegen_;
6561
LPointerMap* pointers_;
6662
int deoptimization_index_;
67-
bool ensure_reloc_space_;
6863
};
6964

7065

@@ -87,6 +82,7 @@ void LCodeGen::FinishCode(Handle<Code> code) {
8782
code->set_stack_slots(StackSlotCount());
8883
code->set_safepoint_table_offset(safepoints_.GetCodeOffset());
8984
PopulateDeoptimizationData(code);
85+
Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code);
9086
}
9187

9288

@@ -2220,8 +2216,7 @@ void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
22202216
RegisterEnvironmentForDeoptimization(env);
22212217
SafepointGenerator safepoint_generator(this,
22222218
pointers,
2223-
env->deoptimization_index(),
2224-
true);
2219+
env->deoptimization_index());
22252220
v8::internal::ParameterCount actual(rax);
22262221
__ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator);
22272222
}
@@ -3597,8 +3592,7 @@ void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) {
35973592
// builtin)
35983593
SafepointGenerator safepoint_generator(this,
35993594
pointers,
3600-
env->deoptimization_index(),
3601-
true);
3595+
env->deoptimization_index());
36023596
__ Push(Smi::FromInt(strict_mode_flag()));
36033597
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator);
36043598
}

0 commit comments

Comments
 (0)