2012-12-18 16:25:45 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#include "v8.h"
|
|
|
|
|
|
|
|
#include "code-stubs.h"
|
|
|
|
#include "hydrogen.h"
|
|
|
|
#include "lithium.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
2013-01-28 13:24:41 +00:00
|
|
|
static LChunk* OptimizeGraph(HGraph* graph) {
|
2013-06-03 15:32:22 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
DisallowHandleAllocation no_handles;
|
|
|
|
DisallowHandleDereference no_deref;
|
2013-01-28 13:24:41 +00:00
|
|
|
|
|
|
|
ASSERT(graph != NULL);
|
2013-08-02 09:53:11 +00:00
|
|
|
BailoutReason bailout_reason = kNoReason;
|
2013-01-28 13:24:41 +00:00
|
|
|
if (!graph->Optimize(&bailout_reason)) {
|
2013-08-02 09:53:11 +00:00
|
|
|
FATAL(GetBailoutReason(bailout_reason));
|
2013-01-28 13:24:41 +00:00
|
|
|
}
|
2012-12-18 16:25:45 +00:00
|
|
|
LChunk* chunk = LChunk::NewChunk(graph);
|
2013-01-28 13:24:41 +00:00
|
|
|
if (chunk == NULL) {
|
2013-08-02 09:53:11 +00:00
|
|
|
FATAL(GetBailoutReason(graph->info()->bailout_reason()));
|
2013-01-28 13:24:41 +00:00
|
|
|
}
|
|
|
|
return chunk;
|
2012-12-18 16:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class CodeStubGraphBuilderBase : public HGraphBuilder {
|
|
|
|
public:
|
|
|
|
CodeStubGraphBuilderBase(Isolate* isolate, HydrogenCodeStub* stub)
|
2013-03-08 21:07:55 +00:00
|
|
|
: HGraphBuilder(&info_),
|
|
|
|
arguments_length_(NULL),
|
|
|
|
info_(stub, isolate),
|
|
|
|
context_(NULL) {
|
2014-04-24 12:07:40 +00:00
|
|
|
descriptor_ = stub->GetInterfaceDescriptor();
|
2013-02-25 14:03:09 +00:00
|
|
|
parameters_.Reset(new HParameter*[descriptor_->register_param_count_]);
|
|
|
|
}
|
2012-12-18 16:25:45 +00:00
|
|
|
virtual bool BuildGraph();
|
|
|
|
|
|
|
|
protected:
|
2013-03-08 21:07:55 +00:00
|
|
|
virtual HValue* BuildCodeStub() = 0;
|
|
|
|
HParameter* GetParameter(int parameter) {
|
|
|
|
ASSERT(parameter < descriptor_->register_param_count_);
|
|
|
|
return parameters_[parameter];
|
|
|
|
}
|
|
|
|
HValue* GetArgumentsLength() {
|
|
|
|
// This is initialized in BuildGraph()
|
|
|
|
ASSERT(arguments_length_ != NULL);
|
|
|
|
return arguments_length_;
|
|
|
|
}
|
2013-02-04 12:01:59 +00:00
|
|
|
CompilationInfo* info() { return &info_; }
|
2012-12-18 16:25:45 +00:00
|
|
|
HydrogenCodeStub* stub() { return info_.code_stub(); }
|
2012-12-28 16:25:38 +00:00
|
|
|
HContext* context() { return context_; }
|
2013-02-04 12:01:59 +00:00
|
|
|
Isolate* isolate() { return info_.isolate(); }
|
2012-12-18 16:25:45 +00:00
|
|
|
|
2014-02-17 13:23:04 +00:00
|
|
|
HLoadNamedField* BuildLoadNamedField(HValue* object,
|
|
|
|
Representation representation,
|
|
|
|
int offset,
|
|
|
|
bool is_inobject);
|
|
|
|
|
2013-06-05 10:43:18 +00:00
|
|
|
enum ArgumentClass {
|
|
|
|
NONE,
|
|
|
|
SINGLE,
|
|
|
|
MULTIPLE
|
|
|
|
};
|
|
|
|
|
|
|
|
HValue* BuildArrayConstructor(ElementsKind kind,
|
2013-06-28 13:16:14 +00:00
|
|
|
AllocationSiteOverrideMode override_mode,
|
2013-06-05 10:43:18 +00:00
|
|
|
ArgumentClass argument_class);
|
|
|
|
HValue* BuildInternalArrayConstructor(ElementsKind kind,
|
|
|
|
ArgumentClass argument_class);
|
|
|
|
|
2014-03-12 13:29:42 +00:00
|
|
|
// BuildCheckAndInstallOptimizedCode emits code to install the optimized
|
|
|
|
// function found in the optimized code map at map_index in js_function, if
|
|
|
|
// the function at map_index matches the given native_context. Builder is
|
|
|
|
// left in the "Then()" state after the install.
|
|
|
|
void BuildCheckAndInstallOptimizedCode(HValue* js_function,
|
|
|
|
HValue* native_context,
|
|
|
|
IfBuilder* builder,
|
|
|
|
HValue* optimized_map,
|
|
|
|
HValue* map_index);
|
2013-08-27 11:55:08 +00:00
|
|
|
void BuildInstallCode(HValue* js_function, HValue* shared_info);
|
2014-03-12 13:29:42 +00:00
|
|
|
|
|
|
|
HInstruction* LoadFromOptimizedCodeMap(HValue* optimized_map,
|
|
|
|
HValue* iterator,
|
|
|
|
int field_offset);
|
2013-08-27 11:55:08 +00:00
|
|
|
void BuildInstallFromOptimizedCodeMap(HValue* js_function,
|
|
|
|
HValue* shared_info,
|
|
|
|
HValue* native_context);
|
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
private:
|
2013-06-05 10:43:18 +00:00
|
|
|
HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder);
|
|
|
|
HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder,
|
|
|
|
ElementsKind kind);
|
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
SmartArrayPointer<HParameter*> parameters_;
|
2013-03-08 21:07:55 +00:00
|
|
|
HValue* arguments_length_;
|
2012-12-18 16:25:45 +00:00
|
|
|
CompilationInfoWithZone info_;
|
2013-02-25 14:03:09 +00:00
|
|
|
CodeStubInterfaceDescriptor* descriptor_;
|
2012-12-28 16:25:38 +00:00
|
|
|
HContext* context_;
|
2012-12-18 16:25:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
bool CodeStubGraphBuilderBase::BuildGraph() {
|
2013-04-18 20:37:27 +00:00
|
|
|
// Update the static counter each time a new code stub is generated.
|
|
|
|
isolate()->counters()->code_stubs()->Increment();
|
|
|
|
|
2013-07-24 12:38:52 +00:00
|
|
|
if (FLAG_trace_hydrogen_stubs) {
|
2013-02-08 11:56:15 +00:00
|
|
|
const char* name = CodeStub::MajorName(stub()->MajorKey(), false);
|
2012-12-18 16:25:45 +00:00
|
|
|
PrintF("-----------------------------------------------------------\n");
|
2013-02-08 11:56:15 +00:00
|
|
|
PrintF("Compiling stub %s using hydrogen\n", name);
|
2013-03-06 07:25:46 +00:00
|
|
|
isolate()->GetHTracer()->TraceCompilation(&info_);
|
2012-12-18 16:25:45 +00:00
|
|
|
}
|
|
|
|
|
2013-03-08 21:07:55 +00:00
|
|
|
int param_count = descriptor_->register_param_count_;
|
|
|
|
HEnvironment* start_environment = graph()->start_environment();
|
2013-04-17 14:11:39 +00:00
|
|
|
HBasicBlock* next_block = CreateBasicBlock(start_environment);
|
2013-10-21 13:35:48 +00:00
|
|
|
Goto(next_block);
|
2013-02-25 14:03:09 +00:00
|
|
|
next_block->SetJoinId(BailoutId::StubEntry());
|
|
|
|
set_current_block(next_block);
|
|
|
|
|
2013-11-13 10:07:04 +00:00
|
|
|
bool runtime_stack_params = descriptor_->stack_parameter_count_.is_valid();
|
|
|
|
HInstruction* stack_parameter_count = NULL;
|
2013-02-25 14:03:09 +00:00
|
|
|
for (int i = 0; i < param_count; ++i) {
|
2013-11-13 10:07:04 +00:00
|
|
|
Representation r = descriptor_->IsParameterCountRegister(i)
|
|
|
|
? Representation::Integer32()
|
|
|
|
: Representation::Tagged();
|
|
|
|
HParameter* param = Add<HParameter>(i, HParameter::REGISTER_PARAMETER, r);
|
2013-02-25 14:03:09 +00:00
|
|
|
start_environment->Bind(i, param);
|
2012-12-18 16:25:45 +00:00
|
|
|
parameters_[i] = param;
|
2013-11-13 10:07:04 +00:00
|
|
|
if (descriptor_->IsParameterCountRegister(i)) {
|
|
|
|
param->set_type(HType::Smi());
|
|
|
|
stack_parameter_count = param;
|
|
|
|
arguments_length_ = stack_parameter_count;
|
|
|
|
}
|
2012-12-18 16:25:45 +00:00
|
|
|
}
|
2013-02-04 12:01:59 +00:00
|
|
|
|
2013-11-13 10:07:04 +00:00
|
|
|
ASSERT(!runtime_stack_params || arguments_length_ != NULL);
|
|
|
|
if (!runtime_stack_params) {
|
2013-03-12 15:37:23 +00:00
|
|
|
stack_parameter_count = graph()->GetConstantMinus1();
|
|
|
|
arguments_length_ = graph()->GetConstant0();
|
2013-03-08 21:07:55 +00:00
|
|
|
}
|
|
|
|
|
2013-10-22 11:29:05 +00:00
|
|
|
context_ = Add<HContext>();
|
2013-03-08 21:07:55 +00:00
|
|
|
start_environment->BindContext(context_);
|
2013-02-04 12:01:59 +00:00
|
|
|
|
2013-07-23 13:35:10 +00:00
|
|
|
Add<HSimulate>(BailoutId::StubEntry());
|
2012-12-18 16:25:45 +00:00
|
|
|
|
2013-04-11 13:07:37 +00:00
|
|
|
NoObservableSideEffectsScope no_effects(this);
|
|
|
|
|
2013-03-08 21:07:55 +00:00
|
|
|
HValue* return_value = BuildCodeStub();
|
2013-04-02 11:28:01 +00:00
|
|
|
|
|
|
|
// We might have extra expressions to pop from the stack in addition to the
|
2013-05-23 09:17:01 +00:00
|
|
|
// arguments above.
|
2013-04-02 11:28:01 +00:00
|
|
|
HInstruction* stack_pop_count = stack_parameter_count;
|
|
|
|
if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) {
|
2013-04-25 16:00:32 +00:00
|
|
|
if (!stack_parameter_count->IsConstant() &&
|
|
|
|
descriptor_->hint_stack_parameter_count_ < 0) {
|
2013-11-13 10:07:04 +00:00
|
|
|
HInstruction* constant_one = graph()->GetConstant1();
|
2013-11-22 19:05:21 +00:00
|
|
|
stack_pop_count = AddUncasted<HAdd>(stack_parameter_count, constant_one);
|
2013-04-25 16:00:32 +00:00
|
|
|
stack_pop_count->ClearFlag(HValue::kCanOverflow);
|
2013-11-13 10:07:04 +00:00
|
|
|
// TODO(mvstanton): verify that stack_parameter_count+1 really fits in a
|
|
|
|
// smi.
|
2013-04-25 16:00:32 +00:00
|
|
|
} else {
|
|
|
|
int count = descriptor_->hint_stack_parameter_count_;
|
2013-07-31 14:58:39 +00:00
|
|
|
stack_pop_count = Add<HConstant>(count);
|
2013-04-25 16:00:32 +00:00
|
|
|
}
|
2013-04-02 11:28:01 +00:00
|
|
|
}
|
|
|
|
|
2013-05-29 12:36:41 +00:00
|
|
|
if (current_block() != NULL) {
|
2013-07-31 14:58:39 +00:00
|
|
|
HReturn* hreturn_instruction = New<HReturn>(return_value,
|
|
|
|
stack_pop_count);
|
2013-10-21 13:35:48 +00:00
|
|
|
FinishCurrentBlock(hreturn_instruction);
|
2013-04-24 11:32:17 +00:00
|
|
|
}
|
2012-12-18 16:25:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-02 11:28:01 +00:00
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
template <class Stub>
|
|
|
|
class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
|
|
|
|
public:
|
2013-11-16 15:22:09 +00:00
|
|
|
CodeStubGraphBuilder(Isolate* isolate, Stub* stub)
|
2013-09-03 06:57:16 +00:00
|
|
|
: CodeStubGraphBuilderBase(isolate, stub) {}
|
2012-12-18 16:25:45 +00:00
|
|
|
|
|
|
|
protected:
|
2013-04-18 20:37:27 +00:00
|
|
|
virtual HValue* BuildCodeStub() {
|
2013-05-24 11:44:55 +00:00
|
|
|
if (casted_stub()->IsUninitialized()) {
|
2013-04-18 20:37:27 +00:00
|
|
|
return BuildCodeUninitializedStub();
|
2013-05-24 11:44:55 +00:00
|
|
|
} else {
|
|
|
|
return BuildCodeInitializedStub();
|
2013-04-18 20:37:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual HValue* BuildCodeInitializedStub() {
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual HValue* BuildCodeUninitializedStub() {
|
|
|
|
// Force a deopt that falls back to the runtime.
|
|
|
|
HValue* undefined = graph()->GetConstantUndefined();
|
2013-04-22 11:15:43 +00:00
|
|
|
IfBuilder builder(this);
|
|
|
|
builder.IfNot<HCompareObjectEqAndBranch, HValue*>(undefined, undefined);
|
|
|
|
builder.Then();
|
2013-08-09 12:50:42 +00:00
|
|
|
builder.ElseDeopt("Forced deopt to runtime");
|
2013-04-18 20:37:27 +00:00
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
Stub* casted_stub() { return static_cast<Stub*>(stub()); }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> HydrogenCodeStub::GenerateLightweightMissCode() {
|
|
|
|
Factory* factory = isolate()->factory();
|
2013-04-18 20:37:27 +00:00
|
|
|
|
|
|
|
// Generate the new code.
|
2014-04-24 12:07:40 +00:00
|
|
|
MacroAssembler masm(isolate(), NULL, 256);
|
2013-04-18 20:37:27 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// Update the static counter each time a new code stub is generated.
|
2014-04-24 12:07:40 +00:00
|
|
|
isolate()->counters()->code_stubs()->Increment();
|
2013-04-18 20:37:27 +00:00
|
|
|
|
|
|
|
// Generate the code for the stub.
|
|
|
|
masm.set_generating_stub(true);
|
|
|
|
NoCurrentFrameScope scope(&masm);
|
|
|
|
GenerateLightweightMiss(&masm);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the code object.
|
|
|
|
CodeDesc desc;
|
|
|
|
masm.GetCode(&desc);
|
|
|
|
|
|
|
|
// Copy the generated code into a heap object.
|
|
|
|
Code::Flags flags = Code::ComputeFlags(
|
|
|
|
GetCodeKind(),
|
|
|
|
GetICState(),
|
|
|
|
GetExtraICState(),
|
2014-02-14 15:15:08 +00:00
|
|
|
GetStubType());
|
2013-04-18 20:37:27 +00:00
|
|
|
Handle<Code> new_object = factory->NewCode(
|
|
|
|
desc, flags, masm.CodeObject(), NeedsImmovableCode());
|
|
|
|
return new_object;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-20 12:01:49 +00:00
|
|
|
template <class Stub>
|
2014-04-24 12:07:40 +00:00
|
|
|
static Handle<Code> DoGenerateCode(Stub* stub) {
|
|
|
|
Isolate* isolate = stub->isolate();
|
2013-04-18 20:37:27 +00:00
|
|
|
CodeStub::Major major_key =
|
|
|
|
static_cast<HydrogenCodeStub*>(stub)->MajorKey();
|
|
|
|
CodeStubInterfaceDescriptor* descriptor =
|
|
|
|
isolate->code_stub_interface_descriptor(major_key);
|
|
|
|
if (descriptor->register_param_count_ < 0) {
|
2014-04-24 12:07:40 +00:00
|
|
|
stub->InitializeInterfaceDescriptor(descriptor);
|
2013-04-18 20:37:27 +00:00
|
|
|
}
|
2013-05-24 11:44:55 +00:00
|
|
|
|
|
|
|
// If we are uninitialized we can use a light-weight stub to enter
|
2013-04-18 20:37:27 +00:00
|
|
|
// the runtime that is significantly faster than using the standard
|
|
|
|
// stub-failure deopt mechanism.
|
2013-05-24 11:44:55 +00:00
|
|
|
if (stub->IsUninitialized() && descriptor->has_miss_handler()) {
|
2013-10-18 14:55:21 +00:00
|
|
|
ASSERT(!descriptor->stack_parameter_count_.is_valid());
|
2014-04-24 12:07:40 +00:00
|
|
|
return stub->GenerateLightweightMissCode();
|
2013-04-18 20:37:27 +00:00
|
|
|
}
|
2013-10-02 11:27:37 +00:00
|
|
|
ElapsedTimer timer;
|
|
|
|
if (FLAG_profile_hydrogen_code_stub_compilation) {
|
|
|
|
timer.Start();
|
|
|
|
}
|
2013-09-03 06:57:16 +00:00
|
|
|
CodeStubGraphBuilder<Stub> builder(isolate, stub);
|
2013-05-24 11:44:55 +00:00
|
|
|
LChunk* chunk = OptimizeGraph(builder.CreateGraph());
|
2013-10-02 11:27:37 +00:00
|
|
|
Handle<Code> code = chunk->Codegen();
|
|
|
|
if (FLAG_profile_hydrogen_code_stub_compilation) {
|
|
|
|
double ms = timer.Elapsed().InMillisecondsF();
|
2013-12-09 07:41:20 +00:00
|
|
|
PrintF("[Lazy compilation of %s took %0.3f ms]\n",
|
|
|
|
stub->GetName().get(), ms);
|
2013-10-02 11:27:37 +00:00
|
|
|
}
|
|
|
|
return code;
|
2013-03-20 12:01:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-23 06:02:54 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<ToNumberStub>::BuildCodeStub() {
|
|
|
|
HValue* value = GetParameter(0);
|
|
|
|
|
|
|
|
// Check if the parameter is already a SMI or heap number.
|
|
|
|
IfBuilder if_number(this);
|
|
|
|
if_number.If<HIsSmiAndBranch>(value);
|
2014-02-25 16:11:58 +00:00
|
|
|
if_number.OrIf<HCompareMap>(value, isolate()->factory()->heap_number_map());
|
2013-07-23 06:02:54 +00:00
|
|
|
if_number.Then();
|
|
|
|
|
|
|
|
// Return the number.
|
|
|
|
Push(value);
|
|
|
|
|
|
|
|
if_number.Else();
|
|
|
|
|
|
|
|
// Convert the parameter to number using the builtin.
|
2013-07-31 14:58:39 +00:00
|
|
|
HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER);
|
2013-07-23 06:02:54 +00:00
|
|
|
Add<HPushArgument>(value);
|
2013-07-31 14:58:39 +00:00
|
|
|
Push(Add<HInvokeFunction>(function, 1));
|
2013-07-23 06:02:54 +00:00
|
|
|
|
|
|
|
if_number.End();
|
|
|
|
|
|
|
|
return Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> ToNumberStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-07-23 06:02:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-24 09:31:07 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<NumberToStringStub>::BuildCodeStub() {
|
|
|
|
info()->MarkAsSavesCallerDoubles();
|
|
|
|
HValue* number = GetParameter(NumberToStringStub::kNumber);
|
2014-01-21 16:22:52 +00:00
|
|
|
return BuildNumberToString(number, Type::Number(zone()));
|
2013-09-24 09:31:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> NumberToStringStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-09-24 09:31:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-04 17:55:43 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
|
|
|
|
Factory* factory = isolate()->factory();
|
2013-04-22 11:15:43 +00:00
|
|
|
HValue* undefined = graph()->GetConstantUndefined();
|
2013-04-04 17:55:43 +00:00
|
|
|
AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode();
|
|
|
|
FastCloneShallowArrayStub::Mode mode = casted_stub()->mode();
|
|
|
|
int length = casted_stub()->length();
|
|
|
|
|
2013-07-31 14:58:39 +00:00
|
|
|
HInstruction* allocation_site = Add<HLoadKeyed>(GetParameter(0),
|
|
|
|
GetParameter(1),
|
|
|
|
static_cast<HValue*>(NULL),
|
|
|
|
FAST_ELEMENTS);
|
2013-04-22 11:15:43 +00:00
|
|
|
IfBuilder checker(this);
|
2013-07-31 14:58:39 +00:00
|
|
|
checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site,
|
|
|
|
undefined);
|
2013-04-22 11:15:43 +00:00
|
|
|
checker.Then();
|
2013-04-04 17:55:43 +00:00
|
|
|
|
2013-10-28 09:36:49 +00:00
|
|
|
HObjectAccess access = HObjectAccess::ForAllocationSiteOffset(
|
|
|
|
AllocationSite::kTransitionInfoOffset);
|
2014-01-29 09:48:35 +00:00
|
|
|
HInstruction* boilerplate = Add<HLoadNamedField>(
|
|
|
|
allocation_site, static_cast<HValue*>(NULL), access);
|
2013-09-13 13:50:16 +00:00
|
|
|
HValue* push_value;
|
2013-04-04 17:55:43 +00:00
|
|
|
if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) {
|
2013-08-21 14:49:56 +00:00
|
|
|
HValue* elements = AddLoadElements(boilerplate);
|
2013-04-04 17:55:43 +00:00
|
|
|
|
2013-04-18 10:51:24 +00:00
|
|
|
IfBuilder if_fixed_cow(this);
|
2014-02-25 16:11:58 +00:00
|
|
|
if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map());
|
2013-04-18 10:51:24 +00:00
|
|
|
if_fixed_cow.Then();
|
2013-09-13 13:50:16 +00:00
|
|
|
push_value = BuildCloneShallowArray(boilerplate,
|
|
|
|
allocation_site,
|
|
|
|
alloc_site_mode,
|
|
|
|
FAST_ELEMENTS,
|
|
|
|
0/*copy-on-write*/);
|
|
|
|
environment()->Push(push_value);
|
2013-04-18 10:51:24 +00:00
|
|
|
if_fixed_cow.Else();
|
2013-04-04 17:55:43 +00:00
|
|
|
|
2013-04-18 10:51:24 +00:00
|
|
|
IfBuilder if_fixed(this);
|
2014-02-25 16:11:58 +00:00
|
|
|
if_fixed.If<HCompareMap>(elements, factory->fixed_array_map());
|
2013-04-18 10:51:24 +00:00
|
|
|
if_fixed.Then();
|
2013-09-13 13:50:16 +00:00
|
|
|
push_value = BuildCloneShallowArray(boilerplate,
|
|
|
|
allocation_site,
|
|
|
|
alloc_site_mode,
|
|
|
|
FAST_ELEMENTS,
|
|
|
|
length);
|
|
|
|
environment()->Push(push_value);
|
2013-04-18 10:51:24 +00:00
|
|
|
if_fixed.Else();
|
2013-09-13 13:50:16 +00:00
|
|
|
push_value = BuildCloneShallowArray(boilerplate,
|
|
|
|
allocation_site,
|
|
|
|
alloc_site_mode,
|
|
|
|
FAST_DOUBLE_ELEMENTS,
|
|
|
|
length);
|
|
|
|
environment()->Push(push_value);
|
2013-04-04 17:55:43 +00:00
|
|
|
} else {
|
|
|
|
ElementsKind elements_kind = casted_stub()->ComputeElementsKind();
|
2013-09-13 13:50:16 +00:00
|
|
|
push_value = BuildCloneShallowArray(boilerplate,
|
|
|
|
allocation_site,
|
|
|
|
alloc_site_mode,
|
|
|
|
elements_kind,
|
|
|
|
length);
|
|
|
|
environment()->Push(push_value);
|
2013-04-04 17:55:43 +00:00
|
|
|
}
|
|
|
|
|
2013-08-09 12:50:42 +00:00
|
|
|
checker.ElseDeopt("Uninitialized boilerplate literals");
|
2013-07-23 13:35:10 +00:00
|
|
|
checker.End();
|
|
|
|
|
|
|
|
return environment()->Pop();
|
2013-04-04 17:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> FastCloneShallowArrayStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-04-04 17:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-26 13:08:08 +00:00
|
|
|
template <>
|
2013-03-08 21:07:55 +00:00
|
|
|
HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() {
|
2013-04-22 11:15:43 +00:00
|
|
|
HValue* undefined = graph()->GetConstantUndefined();
|
2013-02-26 13:08:08 +00:00
|
|
|
|
2013-10-11 09:25:14 +00:00
|
|
|
HInstruction* allocation_site = Add<HLoadKeyed>(GetParameter(0),
|
|
|
|
GetParameter(1),
|
|
|
|
static_cast<HValue*>(NULL),
|
|
|
|
FAST_ELEMENTS);
|
2013-02-26 13:08:08 +00:00
|
|
|
|
2013-04-22 11:15:43 +00:00
|
|
|
IfBuilder checker(this);
|
2013-10-11 09:25:14 +00:00
|
|
|
checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site,
|
2013-07-31 14:58:39 +00:00
|
|
|
undefined);
|
2013-04-22 11:15:43 +00:00
|
|
|
checker.And();
|
2013-02-26 13:08:08 +00:00
|
|
|
|
2013-10-28 09:36:49 +00:00
|
|
|
HObjectAccess access = HObjectAccess::ForAllocationSiteOffset(
|
|
|
|
AllocationSite::kTransitionInfoOffset);
|
2014-01-29 09:48:35 +00:00
|
|
|
HInstruction* boilerplate = Add<HLoadNamedField>(
|
|
|
|
allocation_site, static_cast<HValue*>(NULL), access);
|
2013-10-11 09:25:14 +00:00
|
|
|
|
2013-02-26 13:08:08 +00:00
|
|
|
int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize;
|
2013-10-11 09:25:14 +00:00
|
|
|
int object_size = size;
|
|
|
|
if (FLAG_allocation_site_pretenuring) {
|
|
|
|
size += AllocationMemento::kSize;
|
|
|
|
}
|
|
|
|
|
2013-10-04 19:04:34 +00:00
|
|
|
HValue* boilerplate_map = Add<HLoadNamedField>(
|
2014-01-29 09:48:35 +00:00
|
|
|
boilerplate, static_cast<HValue*>(NULL),
|
|
|
|
HObjectAccess::ForMap());
|
2013-10-04 19:04:34 +00:00
|
|
|
HValue* boilerplate_size = Add<HLoadNamedField>(
|
2014-01-29 09:48:35 +00:00
|
|
|
boilerplate_map, static_cast<HValue*>(NULL),
|
|
|
|
HObjectAccess::ForMapInstanceSize());
|
2013-10-11 09:25:14 +00:00
|
|
|
HValue* size_in_words = Add<HConstant>(object_size >> kPointerSizeLog2);
|
2013-07-05 10:40:14 +00:00
|
|
|
checker.If<HCompareNumericAndBranch>(boilerplate_size,
|
|
|
|
size_in_words, Token::EQ);
|
2013-04-22 11:15:43 +00:00
|
|
|
checker.Then();
|
2013-02-26 13:08:08 +00:00
|
|
|
|
2013-07-31 14:58:39 +00:00
|
|
|
HValue* size_in_bytes = Add<HConstant>(size);
|
2013-05-24 08:38:21 +00:00
|
|
|
|
2013-07-31 14:58:39 +00:00
|
|
|
HInstruction* object = Add<HAllocate>(size_in_bytes, HType::JSObject(),
|
2013-12-18 22:43:56 +00:00
|
|
|
NOT_TENURED, JS_OBJECT_TYPE);
|
2013-02-26 13:08:08 +00:00
|
|
|
|
2013-10-11 09:25:14 +00:00
|
|
|
for (int i = 0; i < object_size; i += kPointerSize) {
|
2014-02-04 10:48:49 +00:00
|
|
|
HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset(i);
|
2014-01-29 09:48:35 +00:00
|
|
|
Add<HStoreNamedField>(
|
|
|
|
object, access, Add<HLoadNamedField>(
|
2014-02-04 10:48:49 +00:00
|
|
|
boilerplate, static_cast<HValue*>(NULL), access));
|
2013-02-26 13:08:08 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 09:25:14 +00:00
|
|
|
ASSERT(FLAG_allocation_site_pretenuring || (size == object_size));
|
|
|
|
if (FLAG_allocation_site_pretenuring) {
|
2013-12-02 11:24:31 +00:00
|
|
|
BuildCreateAllocationMemento(
|
|
|
|
object, Add<HConstant>(object_size), allocation_site);
|
2013-10-11 09:25:14 +00:00
|
|
|
}
|
|
|
|
|
2013-07-23 13:35:10 +00:00
|
|
|
environment()->Push(object);
|
2013-08-09 12:50:42 +00:00
|
|
|
checker.ElseDeopt("Uninitialized boilerplate in fast clone");
|
2013-07-23 13:35:10 +00:00
|
|
|
checker.End();
|
|
|
|
|
|
|
|
return environment()->Pop();
|
2013-02-26 13:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> FastCloneShallowObjectStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-02-26 13:08:08 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 12:01:57 +00:00
|
|
|
|
2013-07-08 10:02:16 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
|
2013-07-31 13:45:51 +00:00
|
|
|
HValue* size = Add<HConstant>(AllocationSite::kSize);
|
2013-08-01 08:34:36 +00:00
|
|
|
HInstruction* object = Add<HAllocate>(size, HType::JSObject(), TENURED,
|
|
|
|
JS_OBJECT_TYPE);
|
2013-07-08 10:02:16 +00:00
|
|
|
|
|
|
|
// Store the map
|
2013-09-20 09:27:40 +00:00
|
|
|
Handle<Map> allocation_site_map = isolate()->factory()->allocation_site_map();
|
2013-07-08 10:02:16 +00:00
|
|
|
AddStoreMapConstant(object, allocation_site_map);
|
|
|
|
|
|
|
|
// Store the payload (smi elements kind)
|
2013-07-31 13:45:51 +00:00
|
|
|
HValue* initial_elements_kind = Add<HConstant>(GetInitialFastElementsKind());
|
2013-07-17 11:50:24 +00:00
|
|
|
Add<HStoreNamedField>(object,
|
2013-10-28 09:36:49 +00:00
|
|
|
HObjectAccess::ForAllocationSiteOffset(
|
|
|
|
AllocationSite::kTransitionInfoOffset),
|
2014-02-04 10:48:49 +00:00
|
|
|
initial_elements_kind);
|
2013-07-17 11:50:24 +00:00
|
|
|
|
2013-09-24 10:30:41 +00:00
|
|
|
// Unlike literals, constructed arrays don't have nested sites
|
|
|
|
Add<HStoreNamedField>(object,
|
2013-10-28 09:36:49 +00:00
|
|
|
HObjectAccess::ForAllocationSiteOffset(
|
|
|
|
AllocationSite::kNestedSiteOffset),
|
2014-02-04 10:48:49 +00:00
|
|
|
graph()->GetConstant0());
|
2013-09-24 10:30:41 +00:00
|
|
|
|
2014-01-13 10:28:01 +00:00
|
|
|
// Pretenuring calculation field.
|
2013-11-22 07:34:21 +00:00
|
|
|
Add<HStoreNamedField>(object,
|
|
|
|
HObjectAccess::ForAllocationSiteOffset(
|
2014-01-13 10:28:01 +00:00
|
|
|
AllocationSite::kPretenureDataOffset),
|
2014-02-04 10:48:49 +00:00
|
|
|
graph()->GetConstant0());
|
2013-11-22 07:34:21 +00:00
|
|
|
|
2014-01-13 10:28:01 +00:00
|
|
|
// Pretenuring memento creation count field.
|
2013-11-22 07:34:21 +00:00
|
|
|
Add<HStoreNamedField>(object,
|
|
|
|
HObjectAccess::ForAllocationSiteOffset(
|
2014-01-13 10:28:01 +00:00
|
|
|
AllocationSite::kPretenureCreateCountOffset),
|
2014-02-04 10:48:49 +00:00
|
|
|
graph()->GetConstant0());
|
2013-11-22 07:34:21 +00:00
|
|
|
|
2013-09-19 14:13:34 +00:00
|
|
|
// Store an empty fixed array for the code dependency.
|
|
|
|
HConstant* empty_fixed_array =
|
|
|
|
Add<HConstant>(isolate()->factory()->empty_fixed_array());
|
|
|
|
HStoreNamedField* store = Add<HStoreNamedField>(
|
|
|
|
object,
|
2013-10-28 09:36:49 +00:00
|
|
|
HObjectAccess::ForAllocationSiteOffset(
|
|
|
|
AllocationSite::kDependentCodeOffset),
|
2014-02-04 10:48:49 +00:00
|
|
|
empty_fixed_array);
|
2013-09-19 14:13:34 +00:00
|
|
|
|
2013-07-31 10:47:44 +00:00
|
|
|
// Link the object to the allocation site list
|
|
|
|
HValue* site_list = Add<HConstant>(
|
|
|
|
ExternalReference::allocation_sites_list_address(isolate()));
|
2014-01-29 09:48:35 +00:00
|
|
|
HValue* site = Add<HLoadNamedField>(
|
|
|
|
site_list, static_cast<HValue*>(NULL),
|
|
|
|
HObjectAccess::ForAllocationSiteList());
|
2013-09-19 14:13:34 +00:00
|
|
|
store = Add<HStoreNamedField>(object,
|
2013-10-28 09:36:49 +00:00
|
|
|
HObjectAccess::ForAllocationSiteOffset(AllocationSite::kWeakNextOffset),
|
2014-02-04 10:48:49 +00:00
|
|
|
site);
|
2013-07-31 10:47:44 +00:00
|
|
|
store->SkipWriteBarrier();
|
2013-07-31 14:58:39 +00:00
|
|
|
Add<HStoreNamedField>(site_list, HObjectAccess::ForAllocationSiteList(),
|
2014-02-04 10:48:49 +00:00
|
|
|
object);
|
2013-07-08 10:02:16 +00:00
|
|
|
|
2014-02-10 21:38:17 +00:00
|
|
|
HInstruction* feedback_vector = GetParameter(0);
|
|
|
|
HInstruction* slot = GetParameter(1);
|
|
|
|
Add<HStoreKeyed>(feedback_vector, slot, object, FAST_ELEMENTS,
|
|
|
|
INITIALIZING_STORE);
|
|
|
|
return feedback_vector;
|
2013-07-08 10:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> CreateAllocationSiteStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-07-08 10:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
template <>
|
2013-03-08 21:07:55 +00:00
|
|
|
HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
|
2012-12-18 16:25:45 +00:00
|
|
|
HInstruction* load = BuildUncheckedMonomorphicElementAccess(
|
2013-08-26 12:28:08 +00:00
|
|
|
GetParameter(0), GetParameter(1), NULL,
|
2013-01-29 15:46:34 +00:00
|
|
|
casted_stub()->is_js_array(), casted_stub()->elements_kind(),
|
2014-02-10 11:43:34 +00:00
|
|
|
LOAD, NEVER_RETURN_HOLE, STANDARD_STORE);
|
2013-03-08 21:07:55 +00:00
|
|
|
return load;
|
2012-12-18 16:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2012-12-18 16:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-17 13:23:04 +00:00
|
|
|
HLoadNamedField* CodeStubGraphBuilderBase::BuildLoadNamedField(
|
|
|
|
HValue* object,
|
|
|
|
Representation representation,
|
|
|
|
int offset,
|
|
|
|
bool is_inobject) {
|
|
|
|
HObjectAccess access = is_inobject
|
|
|
|
? HObjectAccess::ForObservableJSObjectOffset(offset, representation)
|
|
|
|
: HObjectAccess::ForBackingStoreOffset(offset, representation);
|
|
|
|
if (representation.IsDouble()) {
|
|
|
|
// Load the heap number.
|
|
|
|
object = Add<HLoadNamedField>(
|
|
|
|
object, static_cast<HValue*>(NULL),
|
|
|
|
access.WithRepresentation(Representation::Tagged()));
|
|
|
|
// Load the double value from it.
|
|
|
|
access = HObjectAccess::ForHeapNumberValue();
|
|
|
|
}
|
|
|
|
return Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), access);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-02 16:32:47 +00:00
|
|
|
template<>
|
|
|
|
HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() {
|
2014-02-17 13:23:04 +00:00
|
|
|
return BuildLoadNamedField(GetParameter(0),
|
|
|
|
casted_stub()->representation(),
|
|
|
|
casted_stub()->offset(),
|
|
|
|
casted_stub()->is_inobject());
|
2013-05-02 16:32:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> LoadFieldStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-05-02 16:32:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<>
|
2014-03-13 10:57:07 +00:00
|
|
|
HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() {
|
|
|
|
HValue* string = BuildLoadNamedField(
|
|
|
|
GetParameter(0), Representation::Tagged(), JSValue::kValueOffset, true);
|
|
|
|
return BuildLoadNamedField(
|
|
|
|
string, Representation::Tagged(), String::kLengthOffset, true);
|
2013-05-02 16:32:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> StringLengthStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-05-02 16:32:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-20 10:37:13 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
|
|
|
|
BuildUncheckedMonomorphicElementAccess(
|
2013-08-26 12:28:08 +00:00
|
|
|
GetParameter(0), GetParameter(1), GetParameter(2),
|
2013-03-20 10:37:13 +00:00
|
|
|
casted_stub()->is_js_array(), casted_stub()->elements_kind(),
|
2014-02-10 11:43:34 +00:00
|
|
|
STORE, NEVER_RETURN_HOLE, casted_stub()->store_mode());
|
2013-03-20 10:37:13 +00:00
|
|
|
|
|
|
|
return GetParameter(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> KeyedStoreFastElementStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-03-20 10:37:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-04 12:01:59 +00:00
|
|
|
template <>
|
2013-03-08 21:07:55 +00:00
|
|
|
HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
|
2013-02-04 12:01:59 +00:00
|
|
|
info()->MarkAsSavesCallerDoubles();
|
|
|
|
|
2013-07-17 11:37:20 +00:00
|
|
|
BuildTransitionElementsKind(GetParameter(0),
|
|
|
|
GetParameter(1),
|
|
|
|
casted_stub()->from_kind(),
|
|
|
|
casted_stub()->to_kind(),
|
2014-03-18 13:29:29 +00:00
|
|
|
casted_stub()->is_js_array());
|
2013-05-24 08:38:21 +00:00
|
|
|
|
2013-07-17 11:37:20 +00:00
|
|
|
return GetParameter(0);
|
2013-02-04 12:01:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> TransitionElementsKindStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-03-20 17:20:48 +00:00
|
|
|
}
|
|
|
|
|
2013-06-05 10:43:18 +00:00
|
|
|
HValue* CodeStubGraphBuilderBase::BuildArrayConstructor(
|
2013-06-28 13:16:14 +00:00
|
|
|
ElementsKind kind,
|
|
|
|
AllocationSiteOverrideMode override_mode,
|
2013-06-05 10:43:18 +00:00
|
|
|
ArgumentClass argument_class) {
|
|
|
|
HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor);
|
2014-01-21 16:04:39 +00:00
|
|
|
HValue* alloc_site = GetParameter(ArrayConstructorStubBase::kAllocationSite);
|
2013-07-08 10:02:16 +00:00
|
|
|
JSArrayBuilder array_builder(this, kind, alloc_site, constructor,
|
2013-06-28 13:16:14 +00:00
|
|
|
override_mode);
|
2013-06-05 10:43:18 +00:00
|
|
|
HValue* result = NULL;
|
|
|
|
switch (argument_class) {
|
|
|
|
case NONE:
|
|
|
|
result = array_builder.AllocateEmptyArray();
|
|
|
|
break;
|
|
|
|
case SINGLE:
|
|
|
|
result = BuildArraySingleArgumentConstructor(&array_builder);
|
|
|
|
break;
|
|
|
|
case MULTIPLE:
|
|
|
|
result = BuildArrayNArgumentsConstructor(&array_builder, kind);
|
|
|
|
break;
|
|
|
|
}
|
2013-06-28 13:16:14 +00:00
|
|
|
|
2013-06-05 10:43:18 +00:00
|
|
|
return result;
|
2013-03-01 16:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-05 10:43:18 +00:00
|
|
|
HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor(
|
|
|
|
ElementsKind kind, ArgumentClass argument_class) {
|
|
|
|
HValue* constructor = GetParameter(
|
|
|
|
InternalArrayConstructorStubBase::kConstructor);
|
|
|
|
JSArrayBuilder array_builder(this, kind, constructor);
|
|
|
|
|
|
|
|
HValue* result = NULL;
|
|
|
|
switch (argument_class) {
|
|
|
|
case NONE:
|
|
|
|
result = array_builder.AllocateEmptyArray();
|
|
|
|
break;
|
|
|
|
case SINGLE:
|
|
|
|
result = BuildArraySingleArgumentConstructor(&array_builder);
|
|
|
|
break;
|
|
|
|
case MULTIPLE:
|
|
|
|
result = BuildArrayNArgumentsConstructor(&array_builder, kind);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result;
|
2013-03-01 16:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-05 10:43:18 +00:00
|
|
|
HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor(
|
|
|
|
JSArrayBuilder* array_builder) {
|
2013-04-25 16:00:32 +00:00
|
|
|
// Smi check and range check on the input arg.
|
|
|
|
HValue* constant_one = graph()->GetConstant1();
|
|
|
|
HValue* constant_zero = graph()->GetConstant0();
|
|
|
|
|
2013-07-31 14:58:39 +00:00
|
|
|
HInstruction* elements = Add<HArgumentsElements>(false);
|
2013-10-22 11:29:05 +00:00
|
|
|
HInstruction* argument = Add<HAccessArgumentsAt>(
|
|
|
|
elements, constant_one, constant_zero);
|
2013-04-25 16:00:32 +00:00
|
|
|
|
2013-11-14 12:05:09 +00:00
|
|
|
return BuildAllocateArrayFromLength(array_builder, argument);
|
2013-03-01 16:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-05 10:43:18 +00:00
|
|
|
HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor(
|
|
|
|
JSArrayBuilder* array_builder, ElementsKind kind) {
|
2013-11-28 09:29:57 +00:00
|
|
|
// Insert a bounds check because the number of arguments might exceed
|
|
|
|
// the kInitialMaxFastElementArray limit. This cannot happen for code
|
|
|
|
// that was parsed, but calling via Array.apply(thisArg, [...]) might
|
|
|
|
// trigger it.
|
|
|
|
HValue* length = GetArgumentsLength();
|
|
|
|
HConstant* max_alloc_length =
|
|
|
|
Add<HConstant>(JSObject::kInitialMaxFastElementArray);
|
|
|
|
HValue* checked_length = Add<HBoundsCheck>(length, max_alloc_length);
|
|
|
|
|
2013-04-25 16:00:32 +00:00
|
|
|
// We need to fill with the hole if it's a smi array in the multi-argument
|
|
|
|
// case because we might have to bail out while copying arguments into
|
|
|
|
// the array because they aren't compatible with a smi array.
|
|
|
|
// If it's a double array, no problem, and if it's fast then no
|
|
|
|
// problem either because doubles are boxed.
|
2013-11-14 12:05:09 +00:00
|
|
|
//
|
|
|
|
// TODO(mvstanton): consider an instruction to memset fill the array
|
|
|
|
// with zero in this case instead.
|
|
|
|
JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind)
|
|
|
|
? JSArrayBuilder::FILL_WITH_HOLE
|
|
|
|
: JSArrayBuilder::DONT_FILL_WITH_HOLE;
|
2013-11-28 09:29:57 +00:00
|
|
|
HValue* new_object = array_builder->AllocateArray(checked_length,
|
|
|
|
checked_length,
|
2013-11-14 12:05:09 +00:00
|
|
|
fill_mode);
|
2013-06-05 10:43:18 +00:00
|
|
|
HValue* elements = array_builder->GetElementsLocation();
|
2013-04-25 16:00:32 +00:00
|
|
|
ASSERT(elements != NULL);
|
|
|
|
|
|
|
|
// Now populate the elements correctly.
|
|
|
|
LoopBuilder builder(this,
|
|
|
|
context(),
|
|
|
|
LoopBuilder::kPostIncrement);
|
|
|
|
HValue* start = graph()->GetConstant0();
|
2013-11-28 09:29:57 +00:00
|
|
|
HValue* key = builder.BeginBody(start, checked_length, Token::LT);
|
2013-07-31 14:58:39 +00:00
|
|
|
HInstruction* argument_elements = Add<HArgumentsElements>(false);
|
2013-10-22 11:29:05 +00:00
|
|
|
HInstruction* argument = Add<HAccessArgumentsAt>(
|
2013-11-28 09:29:57 +00:00
|
|
|
argument_elements, checked_length, key);
|
2013-04-25 16:00:32 +00:00
|
|
|
|
2014-02-04 10:48:49 +00:00
|
|
|
Add<HStoreKeyed>(elements, key, argument, kind);
|
2013-04-25 16:00:32 +00:00
|
|
|
builder.EndBody();
|
|
|
|
return new_object;
|
2013-03-01 16:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-05 10:43:18 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() {
|
|
|
|
ElementsKind kind = casted_stub()->elements_kind();
|
2013-06-28 13:16:14 +00:00
|
|
|
AllocationSiteOverrideMode override_mode = casted_stub()->override_mode();
|
2014-01-09 15:07:23 +00:00
|
|
|
return BuildArrayConstructor(kind, override_mode, NONE);
|
2013-06-05 10:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-06-05 10:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>::
|
|
|
|
BuildCodeStub() {
|
|
|
|
ElementsKind kind = casted_stub()->elements_kind();
|
2013-06-28 13:16:14 +00:00
|
|
|
AllocationSiteOverrideMode override_mode = casted_stub()->override_mode();
|
2014-01-09 15:07:23 +00:00
|
|
|
return BuildArrayConstructor(kind, override_mode, SINGLE);
|
2013-06-05 10:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-06-05 10:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() {
|
|
|
|
ElementsKind kind = casted_stub()->elements_kind();
|
2013-06-28 13:16:14 +00:00
|
|
|
AllocationSiteOverrideMode override_mode = casted_stub()->override_mode();
|
2014-01-09 15:07:23 +00:00
|
|
|
return BuildArrayConstructor(kind, override_mode, MULTIPLE);
|
2013-06-05 10:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-03-01 16:06:34 +00:00
|
|
|
}
|
|
|
|
|
2013-04-24 11:32:17 +00:00
|
|
|
|
2013-06-05 10:43:18 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<InternalArrayNoArgumentConstructorStub>::
|
|
|
|
BuildCodeStub() {
|
|
|
|
ElementsKind kind = casted_stub()->elements_kind();
|
|
|
|
return BuildInternalArrayConstructor(kind, NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> InternalArrayNoArgumentConstructorStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-06-05 10:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<InternalArraySingleArgumentConstructorStub>::
|
|
|
|
BuildCodeStub() {
|
|
|
|
ElementsKind kind = casted_stub()->elements_kind();
|
|
|
|
return BuildInternalArrayConstructor(kind, SINGLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> InternalArraySingleArgumentConstructorStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-06-05 10:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<InternalArrayNArgumentsConstructorStub>::
|
|
|
|
BuildCodeStub() {
|
|
|
|
ElementsKind kind = casted_stub()->elements_kind();
|
|
|
|
return BuildInternalArrayConstructor(kind, MULTIPLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> InternalArrayNArgumentsConstructorStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-06-05 10:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-24 11:32:17 +00:00
|
|
|
template <>
|
2013-05-24 11:44:55 +00:00
|
|
|
HValue* CodeStubGraphBuilder<CompareNilICStub>::BuildCodeInitializedStub() {
|
2013-06-12 17:20:37 +00:00
|
|
|
Isolate* isolate = graph()->isolate();
|
2013-04-24 11:32:17 +00:00
|
|
|
CompareNilICStub* stub = casted_stub();
|
|
|
|
HIfContinuation continuation;
|
2013-06-12 17:20:37 +00:00
|
|
|
Handle<Map> sentinel_map(isolate->heap()->meta_map());
|
2014-01-21 16:22:52 +00:00
|
|
|
Type* type = stub->GetType(zone(), sentinel_map);
|
2013-10-21 13:35:48 +00:00
|
|
|
BuildCompareNil(GetParameter(0), type, &continuation);
|
2013-04-24 11:32:17 +00:00
|
|
|
IfBuilder if_nil(this, &continuation);
|
|
|
|
if_nil.Then();
|
|
|
|
if (continuation.IsFalseReachable()) {
|
|
|
|
if_nil.Else();
|
2013-05-27 08:43:58 +00:00
|
|
|
if_nil.Return(graph()->GetConstant0());
|
2013-04-24 11:32:17 +00:00
|
|
|
}
|
|
|
|
if_nil.End();
|
|
|
|
return continuation.IsTrueReachable()
|
2013-05-27 08:43:58 +00:00
|
|
|
? graph()->GetConstant1()
|
2013-04-24 11:32:17 +00:00
|
|
|
: graph()->GetConstantUndefined();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> CompareNilICStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-04-24 11:32:17 +00:00
|
|
|
}
|
|
|
|
|
2013-05-29 14:49:28 +00:00
|
|
|
|
2013-10-04 08:17:11 +00:00
|
|
|
template <>
|
2013-12-02 13:14:07 +00:00
|
|
|
HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() {
|
|
|
|
BinaryOpIC::State state = casted_stub()->state();
|
2013-10-04 08:17:11 +00:00
|
|
|
|
2013-12-02 13:14:07 +00:00
|
|
|
HValue* left = GetParameter(BinaryOpICStub::kLeft);
|
|
|
|
HValue* right = GetParameter(BinaryOpICStub::kRight);
|
|
|
|
|
2014-01-21 16:22:52 +00:00
|
|
|
Type* left_type = state.GetLeftType(zone());
|
|
|
|
Type* right_type = state.GetRightType(zone());
|
|
|
|
Type* result_type = state.GetResultType(zone());
|
2013-10-04 08:17:11 +00:00
|
|
|
|
|
|
|
ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) &&
|
2013-12-02 13:14:07 +00:00
|
|
|
(state.HasSideEffects() || !result_type->Is(Type::None())));
|
2013-10-04 08:17:11 +00:00
|
|
|
|
|
|
|
HValue* result = NULL;
|
2014-01-02 15:31:27 +00:00
|
|
|
HAllocationMode allocation_mode(NOT_TENURED);
|
2013-12-02 13:14:07 +00:00
|
|
|
if (state.op() == Token::ADD &&
|
2013-10-04 08:17:11 +00:00
|
|
|
(left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) &&
|
|
|
|
!left_type->Is(Type::String()) && !right_type->Is(Type::String())) {
|
2013-10-21 12:42:08 +00:00
|
|
|
// For the generic add stub a fast case for string addition is performance
|
2013-10-04 08:17:11 +00:00
|
|
|
// critical.
|
|
|
|
if (left_type->Maybe(Type::String())) {
|
2013-10-21 12:42:08 +00:00
|
|
|
IfBuilder if_leftisstring(this);
|
|
|
|
if_leftisstring.If<HIsStringAndBranch>(left);
|
|
|
|
if_leftisstring.Then();
|
|
|
|
{
|
2013-11-20 12:00:57 +00:00
|
|
|
Push(BuildBinaryOperation(
|
2013-12-02 13:14:07 +00:00
|
|
|
state.op(), left, right,
|
2014-01-21 16:22:52 +00:00
|
|
|
Type::String(zone()), right_type,
|
2014-01-02 15:31:27 +00:00
|
|
|
result_type, state.fixed_right_arg(),
|
|
|
|
allocation_mode));
|
2013-10-21 12:42:08 +00:00
|
|
|
}
|
|
|
|
if_leftisstring.Else();
|
|
|
|
{
|
2013-11-20 12:00:57 +00:00
|
|
|
Push(BuildBinaryOperation(
|
2013-12-02 13:14:07 +00:00
|
|
|
state.op(), left, right,
|
2013-12-04 09:27:48 +00:00
|
|
|
left_type, right_type, result_type,
|
2014-01-02 15:31:27 +00:00
|
|
|
state.fixed_right_arg(), allocation_mode));
|
2013-10-21 12:42:08 +00:00
|
|
|
}
|
|
|
|
if_leftisstring.End();
|
2013-10-04 08:17:11 +00:00
|
|
|
result = Pop();
|
|
|
|
} else {
|
2013-10-21 12:42:08 +00:00
|
|
|
IfBuilder if_rightisstring(this);
|
|
|
|
if_rightisstring.If<HIsStringAndBranch>(right);
|
|
|
|
if_rightisstring.Then();
|
|
|
|
{
|
2013-11-20 12:00:57 +00:00
|
|
|
Push(BuildBinaryOperation(
|
2013-12-02 13:14:07 +00:00
|
|
|
state.op(), left, right,
|
2014-01-21 16:22:52 +00:00
|
|
|
left_type, Type::String(zone()),
|
2014-01-02 15:31:27 +00:00
|
|
|
result_type, state.fixed_right_arg(),
|
|
|
|
allocation_mode));
|
2013-10-21 12:42:08 +00:00
|
|
|
}
|
|
|
|
if_rightisstring.Else();
|
|
|
|
{
|
2013-11-20 12:00:57 +00:00
|
|
|
Push(BuildBinaryOperation(
|
2013-12-02 13:14:07 +00:00
|
|
|
state.op(), left, right,
|
2013-12-04 09:27:48 +00:00
|
|
|
left_type, right_type, result_type,
|
2014-01-02 15:31:27 +00:00
|
|
|
state.fixed_right_arg(), allocation_mode));
|
2013-10-21 12:42:08 +00:00
|
|
|
}
|
|
|
|
if_rightisstring.End();
|
2013-10-04 08:17:11 +00:00
|
|
|
result = Pop();
|
|
|
|
}
|
|
|
|
} else {
|
2013-11-20 12:00:57 +00:00
|
|
|
result = BuildBinaryOperation(
|
2013-12-02 13:14:07 +00:00
|
|
|
state.op(), left, right,
|
2013-12-04 09:27:48 +00:00
|
|
|
left_type, right_type, result_type,
|
2014-01-02 15:31:27 +00:00
|
|
|
state.fixed_right_arg(), allocation_mode);
|
2013-10-04 08:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we encounter a generic argument, the number conversion is
|
|
|
|
// observable, thus we cannot afford to bail out after the fact.
|
2013-12-02 13:14:07 +00:00
|
|
|
if (!state.HasSideEffects()) {
|
2014-03-18 11:50:18 +00:00
|
|
|
if (result_type->Is(Type::SignedSmall())) {
|
2013-12-02 13:14:07 +00:00
|
|
|
if (state.op() == Token::SHR) {
|
2013-10-04 08:17:11 +00:00
|
|
|
// TODO(olivf) Replace this by a SmiTagU Instruction.
|
|
|
|
// 0x40000000: this number would convert to negative when interpreting
|
|
|
|
// the register as signed value;
|
|
|
|
IfBuilder if_of(this);
|
|
|
|
if_of.IfNot<HCompareNumericAndBranch>(result,
|
|
|
|
Add<HConstant>(static_cast<int>(SmiValuesAre32Bits()
|
|
|
|
? 0x80000000 : 0x40000000)), Token::EQ_STRICT);
|
|
|
|
if_of.Then();
|
|
|
|
if_of.ElseDeopt("UInt->Smi oveflow");
|
|
|
|
if_of.End();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = EnforceNumberType(result, result_type);
|
|
|
|
}
|
|
|
|
|
2013-10-14 09:22:34 +00:00
|
|
|
// Reuse the double box of one of the operands if we are allowed to (i.e.
|
|
|
|
// chained binops).
|
2013-12-02 13:14:07 +00:00
|
|
|
if (state.CanReuseDoubleBox()) {
|
|
|
|
HValue* operand = (state.mode() == OVERWRITE_LEFT) ? left : right;
|
2013-10-04 08:17:11 +00:00
|
|
|
IfBuilder if_heap_number(this);
|
2014-04-04 08:46:49 +00:00
|
|
|
if_heap_number.If<HHasInstanceTypeAndBranch>(operand, HEAP_NUMBER_TYPE);
|
2013-10-04 08:17:11 +00:00
|
|
|
if_heap_number.Then();
|
2014-02-04 10:48:49 +00:00
|
|
|
Add<HStoreNamedField>(operand, HObjectAccess::ForHeapNumberValue(), result);
|
2013-10-14 09:22:34 +00:00
|
|
|
Push(operand);
|
2013-10-04 08:17:11 +00:00
|
|
|
if_heap_number.Else();
|
|
|
|
Push(result);
|
|
|
|
if_heap_number.End();
|
|
|
|
result = Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> BinaryOpICStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-10-04 08:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-02 15:31:27 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<BinaryOpWithAllocationSiteStub>::BuildCodeStub() {
|
|
|
|
BinaryOpIC::State state = casted_stub()->state();
|
|
|
|
|
|
|
|
HValue* allocation_site = GetParameter(
|
|
|
|
BinaryOpWithAllocationSiteStub::kAllocationSite);
|
|
|
|
HValue* left = GetParameter(BinaryOpWithAllocationSiteStub::kLeft);
|
|
|
|
HValue* right = GetParameter(BinaryOpWithAllocationSiteStub::kRight);
|
|
|
|
|
2014-01-21 16:22:52 +00:00
|
|
|
Type* left_type = state.GetLeftType(zone());
|
|
|
|
Type* right_type = state.GetRightType(zone());
|
|
|
|
Type* result_type = state.GetResultType(zone());
|
2014-01-02 15:31:27 +00:00
|
|
|
HAllocationMode allocation_mode(allocation_site);
|
|
|
|
|
|
|
|
return BuildBinaryOperation(state.op(), left, right,
|
|
|
|
left_type, right_type, result_type,
|
|
|
|
state.fixed_right_arg(), allocation_mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> BinaryOpWithAllocationSiteStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2014-01-02 15:31:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-12 10:21:08 +00:00
|
|
|
template <>
|
2014-01-22 13:48:05 +00:00
|
|
|
HValue* CodeStubGraphBuilder<StringAddStub>::BuildCodeInitializedStub() {
|
|
|
|
StringAddStub* stub = casted_stub();
|
2013-11-12 10:21:08 +00:00
|
|
|
StringAddFlags flags = stub->flags();
|
|
|
|
PretenureFlag pretenure_flag = stub->pretenure_flag();
|
|
|
|
|
2014-01-22 13:48:05 +00:00
|
|
|
HValue* left = GetParameter(StringAddStub::kLeft);
|
|
|
|
HValue* right = GetParameter(StringAddStub::kRight);
|
2013-11-12 10:21:08 +00:00
|
|
|
|
|
|
|
// Make sure that both arguments are strings if not known in advance.
|
|
|
|
if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
|
2013-11-22 07:27:26 +00:00
|
|
|
left = BuildCheckString(left);
|
2013-11-12 10:21:08 +00:00
|
|
|
}
|
|
|
|
if ((flags & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
|
2013-11-22 07:27:26 +00:00
|
|
|
right = BuildCheckString(right);
|
2013-11-12 10:21:08 +00:00
|
|
|
}
|
|
|
|
|
2014-01-02 15:31:27 +00:00
|
|
|
return BuildStringAdd(left, right, HAllocationMode(pretenure_flag));
|
2013-11-12 10:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> StringAddStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-11-12 10:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-29 14:49:28 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
|
|
|
|
ToBooleanStub* stub = casted_stub();
|
|
|
|
|
|
|
|
IfBuilder if_true(this);
|
|
|
|
if_true.If<HBranch>(GetParameter(0), stub->GetTypes());
|
|
|
|
if_true.Then();
|
2013-07-05 10:34:02 +00:00
|
|
|
if_true.Return(graph()->GetConstant1());
|
2013-05-29 14:49:28 +00:00
|
|
|
if_true.Else();
|
|
|
|
if_true.End();
|
|
|
|
return graph()->GetConstant0();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> ToBooleanStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-05-29 14:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-05 10:34:02 +00:00
|
|
|
template <>
|
|
|
|
HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
|
|
|
|
StoreGlobalStub* stub = casted_stub();
|
|
|
|
Handle<Object> hole(isolate()->heap()->the_hole_value(), isolate());
|
|
|
|
Handle<Object> placeholer_value(Smi::FromInt(0), isolate());
|
|
|
|
Handle<PropertyCell> placeholder_cell =
|
|
|
|
isolate()->factory()->NewPropertyCell(placeholer_value);
|
|
|
|
|
|
|
|
HParameter* value = GetParameter(2);
|
|
|
|
|
2014-03-10 12:23:05 +00:00
|
|
|
if (stub->check_global()) {
|
|
|
|
// Check that the map of the global has not changed: use a placeholder map
|
|
|
|
// that will be replaced later with the global object's map.
|
|
|
|
Handle<Map> placeholder_map = isolate()->factory()->meta_map();
|
|
|
|
HValue* global = Add<HConstant>(
|
|
|
|
StoreGlobalStub::global_placeholder(isolate()));
|
|
|
|
Add<HCheckMaps>(global, placeholder_map, top_info());
|
|
|
|
}
|
2013-07-05 10:40:14 +00:00
|
|
|
|
2013-07-31 14:58:39 +00:00
|
|
|
HValue* cell = Add<HConstant>(placeholder_cell);
|
2013-07-22 14:15:58 +00:00
|
|
|
HObjectAccess access(HObjectAccess::ForCellPayload(isolate()));
|
2014-01-29 09:48:35 +00:00
|
|
|
HValue* cell_contents = Add<HLoadNamedField>(
|
|
|
|
cell, static_cast<HValue*>(NULL), access);
|
2013-07-05 10:34:02 +00:00
|
|
|
|
2013-07-22 14:15:58 +00:00
|
|
|
if (stub->is_constant()) {
|
|
|
|
IfBuilder builder(this);
|
|
|
|
builder.If<HCompareObjectEqAndBranch>(cell_contents, value);
|
|
|
|
builder.Then();
|
2013-08-09 12:50:42 +00:00
|
|
|
builder.ElseDeopt("Unexpected cell contents in constant global store");
|
2013-07-22 14:15:58 +00:00
|
|
|
builder.End();
|
|
|
|
} else {
|
2013-07-05 10:34:02 +00:00
|
|
|
// Load the payload of the global parameter cell. A hole indicates that the
|
|
|
|
// property has been deleted and that the store must be handled by the
|
|
|
|
// runtime.
|
|
|
|
IfBuilder builder(this);
|
2013-07-31 14:58:39 +00:00
|
|
|
HValue* hole_value = Add<HConstant>(hole);
|
2013-07-05 10:34:02 +00:00
|
|
|
builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value);
|
|
|
|
builder.Then();
|
2013-08-09 12:50:42 +00:00
|
|
|
builder.Deopt("Unexpected cell contents in global store");
|
2013-07-05 10:34:02 +00:00
|
|
|
builder.Else();
|
2014-02-04 10:48:49 +00:00
|
|
|
Add<HStoreNamedField>(cell, access, value);
|
2013-07-05 10:34:02 +00:00
|
|
|
builder.End();
|
|
|
|
}
|
2013-07-22 14:15:58 +00:00
|
|
|
|
2013-07-05 10:34:02 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> StoreGlobalStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-07-05 10:34:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-17 11:37:20 +00:00
|
|
|
template<>
|
|
|
|
HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() {
|
|
|
|
HValue* value = GetParameter(0);
|
|
|
|
HValue* map = GetParameter(1);
|
|
|
|
HValue* key = GetParameter(2);
|
|
|
|
HValue* object = GetParameter(3);
|
|
|
|
|
|
|
|
if (FLAG_trace_elements_transitions) {
|
|
|
|
// Tracing elements transitions is the job of the runtime.
|
2013-09-04 07:27:10 +00:00
|
|
|
Add<HDeoptimize>("Tracing elements transitions", Deoptimizer::EAGER);
|
2013-07-17 11:37:20 +00:00
|
|
|
} else {
|
|
|
|
info()->MarkAsSavesCallerDoubles();
|
|
|
|
|
|
|
|
BuildTransitionElementsKind(object, map,
|
|
|
|
casted_stub()->from_kind(),
|
|
|
|
casted_stub()->to_kind(),
|
|
|
|
casted_stub()->is_jsarray());
|
|
|
|
|
2013-08-26 12:28:08 +00:00
|
|
|
BuildUncheckedMonomorphicElementAccess(object, key, value,
|
|
|
|
casted_stub()->is_jsarray(),
|
|
|
|
casted_stub()->to_kind(),
|
2014-02-10 11:43:34 +00:00
|
|
|
STORE, ALLOW_RETURN_HOLE,
|
2013-08-26 12:28:08 +00:00
|
|
|
casted_stub()->store_mode());
|
2013-07-17 11:37:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-07-17 11:37:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-12 13:29:42 +00:00
|
|
|
void CodeStubGraphBuilderBase::BuildCheckAndInstallOptimizedCode(
|
2013-08-27 11:55:08 +00:00
|
|
|
HValue* js_function,
|
|
|
|
HValue* native_context,
|
2014-03-12 13:29:42 +00:00
|
|
|
IfBuilder* builder,
|
|
|
|
HValue* optimized_map,
|
|
|
|
HValue* map_index) {
|
|
|
|
HValue* osr_ast_id_none = Add<HConstant>(BailoutId::None().ToInt());
|
|
|
|
HValue* context_slot = LoadFromOptimizedCodeMap(
|
|
|
|
optimized_map, map_index, SharedFunctionInfo::kContextOffset);
|
|
|
|
HValue* osr_ast_slot = LoadFromOptimizedCodeMap(
|
|
|
|
optimized_map, map_index, SharedFunctionInfo::kOsrAstIdOffset);
|
|
|
|
builder->If<HCompareObjectEqAndBranch>(native_context,
|
|
|
|
context_slot);
|
|
|
|
builder->AndIf<HCompareObjectEqAndBranch>(osr_ast_slot, osr_ast_id_none);
|
|
|
|
builder->Then();
|
|
|
|
HValue* code_object = LoadFromOptimizedCodeMap(optimized_map,
|
|
|
|
map_index, SharedFunctionInfo::kCachedCodeOffset);
|
|
|
|
// and the literals
|
|
|
|
HValue* literals = LoadFromOptimizedCodeMap(optimized_map,
|
|
|
|
map_index, SharedFunctionInfo::kLiteralsOffset);
|
|
|
|
|
2013-08-27 11:55:08 +00:00
|
|
|
Counters* counters = isolate()->counters();
|
2013-09-16 11:30:10 +00:00
|
|
|
AddIncrementCounter(counters->fast_new_closure_install_optimized());
|
2013-08-27 11:55:08 +00:00
|
|
|
|
|
|
|
// TODO(fschneider): Idea: store proper code pointers in the optimized code
|
|
|
|
// map and either unmangle them on marking or do nothing as the whole map is
|
|
|
|
// discarded on major GC anyway.
|
|
|
|
Add<HStoreCodeEntry>(js_function, code_object);
|
2014-03-12 13:29:42 +00:00
|
|
|
Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(),
|
|
|
|
literals);
|
2013-08-27 11:55:08 +00:00
|
|
|
|
|
|
|
// Now link a function into a list of optimized functions.
|
2014-01-29 09:48:35 +00:00
|
|
|
HValue* optimized_functions_list = Add<HLoadNamedField>(
|
|
|
|
native_context, static_cast<HValue*>(NULL),
|
2013-08-27 11:55:08 +00:00
|
|
|
HObjectAccess::ForContextSlot(Context::OPTIMIZED_FUNCTIONS_LIST));
|
|
|
|
Add<HStoreNamedField>(js_function,
|
|
|
|
HObjectAccess::ForNextFunctionLinkPointer(),
|
2014-02-04 10:48:49 +00:00
|
|
|
optimized_functions_list);
|
2013-08-27 11:55:08 +00:00
|
|
|
|
|
|
|
// This store is the only one that should have a write barrier.
|
|
|
|
Add<HStoreNamedField>(native_context,
|
|
|
|
HObjectAccess::ForContextSlot(Context::OPTIMIZED_FUNCTIONS_LIST),
|
2014-02-04 10:48:49 +00:00
|
|
|
js_function);
|
2014-03-12 13:29:42 +00:00
|
|
|
|
|
|
|
// The builder continues in the "then" after this function.
|
2013-08-27 11:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CodeStubGraphBuilderBase::BuildInstallCode(HValue* js_function,
|
|
|
|
HValue* shared_info) {
|
|
|
|
Add<HStoreNamedField>(js_function,
|
|
|
|
HObjectAccess::ForNextFunctionLinkPointer(),
|
2014-02-04 10:48:49 +00:00
|
|
|
graph()->GetConstantUndefined());
|
2014-01-29 09:48:35 +00:00
|
|
|
HValue* code_object = Add<HLoadNamedField>(
|
|
|
|
shared_info, static_cast<HValue*>(NULL), HObjectAccess::ForCodeOffset());
|
2013-08-27 11:55:08 +00:00
|
|
|
Add<HStoreCodeEntry>(js_function, code_object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-12 13:29:42 +00:00
|
|
|
HInstruction* CodeStubGraphBuilderBase::LoadFromOptimizedCodeMap(
|
|
|
|
HValue* optimized_map,
|
|
|
|
HValue* iterator,
|
|
|
|
int field_offset) {
|
|
|
|
// By making sure to express these loads in the form [<hvalue> + constant]
|
|
|
|
// the keyed load can be hoisted.
|
|
|
|
ASSERT(field_offset >= 0 && field_offset < SharedFunctionInfo::kEntryLength);
|
|
|
|
HValue* field_slot = iterator;
|
|
|
|
if (field_offset > 0) {
|
|
|
|
HValue* field_offset_value = Add<HConstant>(field_offset);
|
|
|
|
field_slot = AddUncasted<HAdd>(iterator, field_offset_value);
|
|
|
|
}
|
|
|
|
HInstruction* field_entry = Add<HLoadKeyed>(optimized_map, field_slot,
|
|
|
|
static_cast<HValue*>(NULL), FAST_ELEMENTS);
|
|
|
|
return field_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-27 11:55:08 +00:00
|
|
|
void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap(
|
|
|
|
HValue* js_function,
|
|
|
|
HValue* shared_info,
|
|
|
|
HValue* native_context) {
|
|
|
|
Counters* counters = isolate()->counters();
|
|
|
|
IfBuilder is_optimized(this);
|
2014-01-29 09:48:35 +00:00
|
|
|
HInstruction* optimized_map = Add<HLoadNamedField>(
|
|
|
|
shared_info, static_cast<HValue*>(NULL),
|
2013-08-27 11:55:08 +00:00
|
|
|
HObjectAccess::ForOptimizedCodeMap());
|
|
|
|
HValue* null_constant = Add<HConstant>(0);
|
|
|
|
is_optimized.If<HCompareObjectEqAndBranch>(optimized_map, null_constant);
|
|
|
|
is_optimized.Then();
|
|
|
|
{
|
|
|
|
BuildInstallCode(js_function, shared_info);
|
|
|
|
}
|
|
|
|
is_optimized.Else();
|
|
|
|
{
|
2013-09-16 11:30:10 +00:00
|
|
|
AddIncrementCounter(counters->fast_new_closure_try_optimized());
|
2013-08-27 11:55:08 +00:00
|
|
|
// optimized_map points to fixed array of 3-element entries
|
|
|
|
// (native context, optimized code, literals).
|
|
|
|
// Map must never be empty, so check the first elements.
|
2014-03-12 13:29:42 +00:00
|
|
|
HValue* first_entry_index =
|
|
|
|
Add<HConstant>(SharedFunctionInfo::kEntriesStart);
|
2013-08-27 11:55:08 +00:00
|
|
|
IfBuilder already_in(this);
|
2014-03-12 13:29:42 +00:00
|
|
|
BuildCheckAndInstallOptimizedCode(js_function, native_context, &already_in,
|
|
|
|
optimized_map, first_entry_index);
|
2013-08-27 11:55:08 +00:00
|
|
|
already_in.Else();
|
|
|
|
{
|
2014-03-12 13:29:42 +00:00
|
|
|
// Iterate through the rest of map backwards. Do not double check first
|
|
|
|
// entry. After the loop, if no matching optimized code was found,
|
|
|
|
// install unoptimized code.
|
|
|
|
// for(i = map.length() - SharedFunctionInfo::kEntryLength;
|
|
|
|
// i > SharedFunctionInfo::kEntriesStart;
|
|
|
|
// i -= SharedFunctionInfo::kEntryLength) { .. }
|
2013-08-27 11:55:08 +00:00
|
|
|
HValue* shared_function_entry_length =
|
|
|
|
Add<HConstant>(SharedFunctionInfo::kEntryLength);
|
|
|
|
LoopBuilder loop_builder(this,
|
|
|
|
context(),
|
|
|
|
LoopBuilder::kPostDecrement,
|
|
|
|
shared_function_entry_length);
|
2014-01-29 09:48:35 +00:00
|
|
|
HValue* array_length = Add<HLoadNamedField>(
|
|
|
|
optimized_map, static_cast<HValue*>(NULL),
|
2013-08-27 11:55:08 +00:00
|
|
|
HObjectAccess::ForFixedArrayLength());
|
2014-03-12 13:29:42 +00:00
|
|
|
HValue* start_pos = AddUncasted<HSub>(array_length,
|
|
|
|
shared_function_entry_length);
|
|
|
|
HValue* slot_iterator = loop_builder.BeginBody(start_pos,
|
|
|
|
first_entry_index,
|
|
|
|
Token::GT);
|
2013-08-27 11:55:08 +00:00
|
|
|
{
|
2014-03-12 13:29:42 +00:00
|
|
|
IfBuilder done_check(this);
|
|
|
|
BuildCheckAndInstallOptimizedCode(js_function, native_context,
|
|
|
|
&done_check,
|
|
|
|
optimized_map,
|
|
|
|
slot_iterator);
|
|
|
|
// Fall out of the loop
|
|
|
|
loop_builder.Break();
|
2013-08-27 11:55:08 +00:00
|
|
|
}
|
|
|
|
loop_builder.EndBody();
|
2014-03-12 13:29:42 +00:00
|
|
|
|
|
|
|
// If slot_iterator equals first entry index, then we failed to find and
|
|
|
|
// install optimized code
|
|
|
|
IfBuilder no_optimized_code_check(this);
|
|
|
|
no_optimized_code_check.If<HCompareNumericAndBranch>(
|
|
|
|
slot_iterator, first_entry_index, Token::EQ);
|
|
|
|
no_optimized_code_check.Then();
|
|
|
|
{
|
|
|
|
// Store the unoptimized code
|
|
|
|
BuildInstallCode(js_function, shared_info);
|
|
|
|
}
|
2013-08-27 11:55:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
HValue* CodeStubGraphBuilder<FastNewClosureStub>::BuildCodeStub() {
|
|
|
|
Counters* counters = isolate()->counters();
|
|
|
|
Factory* factory = isolate()->factory();
|
|
|
|
HInstruction* empty_fixed_array =
|
|
|
|
Add<HConstant>(factory->empty_fixed_array());
|
|
|
|
HValue* shared_info = GetParameter(0);
|
|
|
|
|
2013-09-20 09:27:40 +00:00
|
|
|
AddIncrementCounter(counters->fast_new_closure_total());
|
|
|
|
|
2013-08-27 11:55:08 +00:00
|
|
|
// Create a new closure from the given function info in new space
|
|
|
|
HValue* size = Add<HConstant>(JSFunction::kSize);
|
|
|
|
HInstruction* js_function = Add<HAllocate>(size, HType::JSObject(),
|
|
|
|
NOT_TENURED, JS_FUNCTION_TYPE);
|
|
|
|
|
2014-03-11 14:41:22 +00:00
|
|
|
int map_index = Context::FunctionMapIndex(casted_stub()->strict_mode(),
|
2013-08-27 11:55:08 +00:00
|
|
|
casted_stub()->is_generator());
|
|
|
|
|
|
|
|
// Compute the function map in the current native context and set that
|
|
|
|
// as the map of the allocated object.
|
|
|
|
HInstruction* native_context = BuildGetNativeContext();
|
2014-01-29 09:48:35 +00:00
|
|
|
HInstruction* map_slot_value = Add<HLoadNamedField>(
|
|
|
|
native_context, static_cast<HValue*>(NULL),
|
2013-08-27 11:55:08 +00:00
|
|
|
HObjectAccess::ForContextSlot(map_index));
|
2014-02-04 10:48:49 +00:00
|
|
|
Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value);
|
2013-08-27 11:55:08 +00:00
|
|
|
|
|
|
|
// Initialize the rest of the function.
|
|
|
|
Add<HStoreNamedField>(js_function, HObjectAccess::ForPropertiesPointer(),
|
2014-02-04 10:48:49 +00:00
|
|
|
empty_fixed_array);
|
2013-08-27 11:55:08 +00:00
|
|
|
Add<HStoreNamedField>(js_function, HObjectAccess::ForElementsPointer(),
|
2014-02-04 10:48:49 +00:00
|
|
|
empty_fixed_array);
|
2013-08-27 11:55:08 +00:00
|
|
|
Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(),
|
2014-02-04 10:48:49 +00:00
|
|
|
empty_fixed_array);
|
2013-08-27 11:55:08 +00:00
|
|
|
Add<HStoreNamedField>(js_function, HObjectAccess::ForPrototypeOrInitialMap(),
|
2014-02-04 10:48:49 +00:00
|
|
|
graph()->GetConstantHole());
|
2013-08-27 11:55:08 +00:00
|
|
|
Add<HStoreNamedField>(js_function,
|
|
|
|
HObjectAccess::ForSharedFunctionInfoPointer(),
|
2014-02-04 10:48:49 +00:00
|
|
|
shared_info);
|
2013-08-27 11:55:08 +00:00
|
|
|
Add<HStoreNamedField>(js_function, HObjectAccess::ForFunctionContextPointer(),
|
2014-02-04 10:48:49 +00:00
|
|
|
context());
|
2013-08-27 11:55:08 +00:00
|
|
|
|
|
|
|
// Initialize the code pointer in the function to be the one
|
|
|
|
// found in the shared function info object.
|
|
|
|
// But first check if there is an optimized version for our context.
|
|
|
|
if (FLAG_cache_optimized_code) {
|
|
|
|
BuildInstallFromOptimizedCodeMap(js_function, shared_info, native_context);
|
|
|
|
} else {
|
|
|
|
BuildInstallCode(js_function, shared_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return js_function;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> FastNewClosureStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-08-27 11:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-23 08:36:22 +00:00
|
|
|
template<>
|
|
|
|
HValue* CodeStubGraphBuilder<FastNewContextStub>::BuildCodeStub() {
|
|
|
|
int length = casted_stub()->slots() + Context::MIN_CONTEXT_SLOTS;
|
|
|
|
|
|
|
|
// Get the function.
|
|
|
|
HParameter* function = GetParameter(FastNewContextStub::kFunction);
|
|
|
|
|
|
|
|
// Allocate the context in new space.
|
|
|
|
HAllocate* function_context = Add<HAllocate>(
|
|
|
|
Add<HConstant>(length * kPointerSize + FixedArray::kHeaderSize),
|
|
|
|
HType::Tagged(), NOT_TENURED, FIXED_ARRAY_TYPE);
|
|
|
|
|
|
|
|
// Set up the object header.
|
|
|
|
AddStoreMapConstant(function_context,
|
|
|
|
isolate()->factory()->function_context_map());
|
|
|
|
Add<HStoreNamedField>(function_context,
|
|
|
|
HObjectAccess::ForFixedArrayLength(),
|
2014-02-04 10:48:49 +00:00
|
|
|
Add<HConstant>(length));
|
2014-01-23 08:36:22 +00:00
|
|
|
|
|
|
|
// Set up the fixed slots.
|
|
|
|
Add<HStoreNamedField>(function_context,
|
|
|
|
HObjectAccess::ForContextSlot(Context::CLOSURE_INDEX),
|
2014-02-04 10:48:49 +00:00
|
|
|
function);
|
2014-01-23 08:36:22 +00:00
|
|
|
Add<HStoreNamedField>(function_context,
|
|
|
|
HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX),
|
2014-02-04 10:48:49 +00:00
|
|
|
context());
|
2014-01-23 08:36:22 +00:00
|
|
|
Add<HStoreNamedField>(function_context,
|
|
|
|
HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX),
|
2014-02-04 10:48:49 +00:00
|
|
|
graph()->GetConstant0());
|
2014-01-23 08:36:22 +00:00
|
|
|
|
|
|
|
// Copy the global object from the previous context.
|
|
|
|
HValue* global_object = Add<HLoadNamedField>(
|
2014-01-29 09:48:35 +00:00
|
|
|
context(), static_cast<HValue*>(NULL),
|
|
|
|
HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
|
2014-01-23 08:36:22 +00:00
|
|
|
Add<HStoreNamedField>(function_context,
|
|
|
|
HObjectAccess::ForContextSlot(
|
|
|
|
Context::GLOBAL_OBJECT_INDEX),
|
2014-02-04 10:48:49 +00:00
|
|
|
global_object);
|
2014-01-23 08:36:22 +00:00
|
|
|
|
|
|
|
// Initialize the rest of the slots to undefined.
|
|
|
|
for (int i = Context::MIN_CONTEXT_SLOTS; i < length; ++i) {
|
|
|
|
Add<HStoreNamedField>(function_context,
|
|
|
|
HObjectAccess::ForContextSlot(i),
|
2014-02-04 10:48:49 +00:00
|
|
|
graph()->GetConstantUndefined());
|
2014-01-23 08:36:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return function_context;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> FastNewContextStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2014-01-23 08:36:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-16 15:22:09 +00:00
|
|
|
template<>
|
2013-11-15 17:53:35 +00:00
|
|
|
HValue* CodeStubGraphBuilder<KeyedLoadDictionaryElementStub>::BuildCodeStub() {
|
2013-11-16 15:22:09 +00:00
|
|
|
HValue* receiver = GetParameter(0);
|
2013-11-15 17:53:35 +00:00
|
|
|
HValue* key = GetParameter(1);
|
|
|
|
|
|
|
|
Add<HCheckSmi>(key);
|
|
|
|
|
2013-11-16 15:22:09 +00:00
|
|
|
return BuildUncheckedDictionaryElementLoad(receiver, key);
|
2013-11-15 17:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2013-11-15 17:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-29 13:10:35 +00:00
|
|
|
template<>
|
|
|
|
HValue* CodeStubGraphBuilder<RegExpConstructResultStub>::BuildCodeStub() {
|
|
|
|
// Determine the parameters.
|
|
|
|
HValue* length = GetParameter(RegExpConstructResultStub::kLength);
|
|
|
|
HValue* index = GetParameter(RegExpConstructResultStub::kIndex);
|
|
|
|
HValue* input = GetParameter(RegExpConstructResultStub::kInput);
|
|
|
|
|
|
|
|
return BuildRegExpConstructResult(length, index, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-24 12:07:40 +00:00
|
|
|
Handle<Code> RegExpConstructResultStub::GenerateCode() {
|
|
|
|
return DoGenerateCode(this);
|
2014-01-29 13:10:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
} } // namespace v8::internal
|