2012-02-10 12:36:05 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
// 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 "bootstrapper.h"
|
|
|
|
#include "code-stubs.h"
|
2013-07-03 15:39:18 +00:00
|
|
|
#include "cpu-profiler.h"
|
2011-05-18 13:17:29 +00:00
|
|
|
#include "stub-cache.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
#include "factory.h"
|
2011-01-18 16:11:01 +00:00
|
|
|
#include "gdb-jit.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
#include "macro-assembler.h"
|
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-04-18 20:37:27 +00:00
|
|
|
|
|
|
|
CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor()
|
|
|
|
: register_param_count_(-1),
|
|
|
|
stack_parameter_count_(NULL),
|
2013-04-25 16:00:32 +00:00
|
|
|
hint_stack_parameter_count_(-1),
|
2013-04-18 20:37:27 +00:00
|
|
|
function_mode_(NOT_JS_FUNCTION_STUB_MODE),
|
|
|
|
register_params_(NULL),
|
|
|
|
deoptimization_handler_(NULL),
|
2013-05-24 11:44:55 +00:00
|
|
|
miss_handler_(IC_Utility(IC::kUnreachable), Isolate::Current()),
|
|
|
|
has_miss_handler_(false) { }
|
2013-04-18 20:37:27 +00:00
|
|
|
|
|
|
|
|
2012-11-22 07:58:59 +00:00
|
|
|
bool CodeStub::FindCodeInCache(Code** code_out, Isolate* isolate) {
|
|
|
|
UnseededNumberDictionary* stubs = isolate->heap()->code_stubs();
|
|
|
|
int index = stubs->FindEntry(GetKey());
|
2012-01-16 09:44:35 +00:00
|
|
|
if (index != UnseededNumberDictionary::kNotFound) {
|
2012-11-22 07:58:59 +00:00
|
|
|
*code_out = Code::cast(stubs->ValueAt(index));
|
2009-12-09 14:54:34 +00:00
|
|
|
return true;
|
2009-11-04 08:51:48 +00:00
|
|
|
}
|
2009-12-09 14:54:34 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-11-04 08:51:48 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-09-09 22:39:47 +00:00
|
|
|
SmartArrayPointer<const char> CodeStub::GetName() {
|
2011-07-13 11:08:25 +00:00
|
|
|
char buffer[100];
|
|
|
|
NoAllocationStringAllocator allocator(buffer,
|
|
|
|
static_cast<unsigned>(sizeof(buffer)));
|
|
|
|
StringStream stream(&allocator);
|
|
|
|
PrintName(&stream);
|
|
|
|
return stream.ToCString();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
void CodeStub::RecordCodeGeneration(Code* code, Isolate* isolate) {
|
2011-09-09 22:39:47 +00:00
|
|
|
SmartArrayPointer<const char> name = GetName();
|
2011-07-13 11:08:25 +00:00
|
|
|
PROFILE(isolate, CodeCreateEvent(Logger::STUB_TAG, code, *name));
|
|
|
|
GDBJIT(AddCode(GDBJITInterface::STUB, *name, code));
|
2011-03-23 11:13:07 +00:00
|
|
|
Counters* counters = isolate->counters();
|
|
|
|
counters->total_stubs_code_size()->Increment(code->instruction_size());
|
2009-12-09 14:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-18 09:50:46 +00:00
|
|
|
Code::Kind CodeStub::GetCodeKind() const {
|
2010-03-01 16:24:05 +00:00
|
|
|
return Code::STUB;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-05 10:34:02 +00:00
|
|
|
Handle<Code> CodeStub::GetCodeCopyFromTemplate(Isolate* isolate) {
|
|
|
|
Handle<Code> ic = GetCode(isolate);
|
|
|
|
ic = isolate->factory()->CopyCode(ic);
|
|
|
|
RecordCodeGeneration(*ic, isolate);
|
|
|
|
return ic;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
Handle<Code> PlatformCodeStub::GenerateCode() {
|
|
|
|
Isolate* isolate = Isolate::Current();
|
|
|
|
Factory* factory = isolate->factory();
|
|
|
|
|
|
|
|
// Generate the new code.
|
|
|
|
MacroAssembler masm(isolate, NULL, 256);
|
|
|
|
|
|
|
|
{
|
|
|
|
// Update the static counter each time a new code stub is generated.
|
|
|
|
isolate->counters()->code_stubs()->Increment();
|
|
|
|
|
|
|
|
// Nested stubs are not allowed for leaves.
|
|
|
|
AllowStubCallsScope allow_scope(&masm, false);
|
|
|
|
|
|
|
|
// Generate the code for the stub.
|
|
|
|
masm.set_generating_stub(true);
|
|
|
|
NoCurrentFrameScope scope(&masm);
|
|
|
|
Generate(&masm);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the code object.
|
|
|
|
CodeDesc desc;
|
|
|
|
masm.GetCode(&desc);
|
|
|
|
|
|
|
|
// Copy the generated code into a heap object.
|
|
|
|
Code::Flags flags = Code::ComputeFlags(
|
2013-04-18 09:50:46 +00:00
|
|
|
GetCodeKind(),
|
2013-03-04 14:03:27 +00:00
|
|
|
GetICState(),
|
|
|
|
GetExtraICState(),
|
2013-03-05 17:38:35 +00:00
|
|
|
GetStubType(),
|
|
|
|
GetStubFlags());
|
2012-12-18 16:25:45 +00:00
|
|
|
Handle<Code> new_object = factory->NewCode(
|
|
|
|
desc, flags, masm.CodeObject(), NeedsImmovableCode());
|
|
|
|
return new_object;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-27 12:33:24 +00:00
|
|
|
Handle<Code> CodeStub::GetCode(Isolate* isolate) {
|
2011-03-28 13:33:48 +00:00
|
|
|
Factory* factory = isolate->factory();
|
|
|
|
Heap* heap = isolate->heap();
|
2009-12-09 14:54:34 +00:00
|
|
|
Code* code;
|
2011-12-09 09:26:14 +00:00
|
|
|
if (UseSpecialCache()
|
2012-11-22 07:58:59 +00:00
|
|
|
? FindCodeInSpecialCache(&code, isolate)
|
|
|
|
: FindCodeInCache(&code, isolate)) {
|
2011-12-09 09:26:14 +00:00
|
|
|
ASSERT(IsPregenerated() == code->is_pregenerated());
|
|
|
|
return Handle<Code>(code);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2011-03-28 13:33:48 +00:00
|
|
|
HandleScope scope(isolate);
|
2009-12-09 14:54:34 +00:00
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
Handle<Code> new_object = GenerateCode();
|
2012-04-26 16:19:14 +00:00
|
|
|
new_object->set_major_key(MajorKey());
|
2011-11-11 13:48:14 +00:00
|
|
|
FinishCode(new_object);
|
2012-12-18 16:25:45 +00:00
|
|
|
RecordCodeGeneration(*new_object, isolate);
|
2012-04-26 16:19:14 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_DISASSEMBLER
|
|
|
|
if (FLAG_print_code_stubs) {
|
|
|
|
new_object->Disassemble(*GetName());
|
|
|
|
PrintF("\n");
|
|
|
|
}
|
|
|
|
#endif
|
2009-12-09 14:54:34 +00:00
|
|
|
|
2011-12-09 09:26:14 +00:00
|
|
|
if (UseSpecialCache()) {
|
|
|
|
AddToSpecialCache(new_object);
|
|
|
|
} else {
|
|
|
|
// Update the dictionary and the root in Heap.
|
2012-01-16 09:44:35 +00:00
|
|
|
Handle<UnseededNumberDictionary> dict =
|
2011-12-09 09:26:14 +00:00
|
|
|
factory->DictionaryAtNumberPut(
|
2012-01-16 09:44:35 +00:00
|
|
|
Handle<UnseededNumberDictionary>(heap->code_stubs()),
|
2011-12-09 09:26:14 +00:00
|
|
|
GetKey(),
|
|
|
|
new_object);
|
|
|
|
heap->public_set_code_stubs(*dict);
|
|
|
|
}
|
2009-12-09 14:54:34 +00:00
|
|
|
code = *new_object;
|
|
|
|
}
|
|
|
|
|
2011-12-09 09:26:14 +00:00
|
|
|
Activate(code);
|
2012-09-14 11:16:56 +00:00
|
|
|
ASSERT(!NeedsImmovableCode() ||
|
|
|
|
heap->lo_space()->Contains(code) ||
|
|
|
|
heap->code_space()->FirstPage()->Contains(code->address()));
|
2011-03-28 13:33:48 +00:00
|
|
|
return Handle<Code>(code, isolate);
|
2009-12-09 14:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-05 13:07:00 +00:00
|
|
|
const char* CodeStub::MajorName(CodeStub::Major major_key,
|
|
|
|
bool allow_unknown_keys) {
|
2008-07-03 15:10:15 +00:00
|
|
|
switch (major_key) {
|
2011-07-08 09:40:14 +00:00
|
|
|
#define DEF_CASE(name) case name: return #name "Stub";
|
2009-11-11 14:32:14 +00:00
|
|
|
CODE_STUB_LIST(DEF_CASE)
|
2009-10-26 12:26:42 +00:00
|
|
|
#undef DEF_CASE
|
2008-07-03 15:10:15 +00:00
|
|
|
default:
|
2010-02-05 13:07:00 +00:00
|
|
|
if (!allow_unknown_keys) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-05 09:52:11 +00:00
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
void CodeStub::PrintBaseName(StringStream* stream) {
|
|
|
|
stream->Add("%s", MajorName(MajorKey(), false));
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-10-03 11:13:20 +00:00
|
|
|
void CodeStub::PrintName(StringStream* stream) {
|
2013-07-05 09:26:22 +00:00
|
|
|
PrintBaseName(stream);
|
|
|
|
PrintState(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Builtins::JavaScript UnaryOpStub::ToJSBuiltin() {
|
|
|
|
switch (operation_) {
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
case Token::SUB:
|
|
|
|
return Builtins::UNARY_MINUS;
|
|
|
|
case Token::BIT_NOT:
|
|
|
|
return Builtins::BIT_NOT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Handle<JSFunction> UnaryOpStub::ToJSFunction(Isolate* isolate) {
|
|
|
|
Handle<JSBuiltinsObject> builtins(isolate->js_builtins_object());
|
|
|
|
Object* builtin = builtins->javascript_builtin(ToJSBuiltin());
|
|
|
|
return Handle<JSFunction>(JSFunction::cast(builtin), isolate);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MaybeObject* UnaryOpStub::Result(Handle<Object> object, Isolate* isolate) {
|
|
|
|
Handle<JSFunction> builtin_function = ToJSFunction(isolate);
|
|
|
|
bool caught_exception;
|
|
|
|
Handle<Object> result = Execution::Call(builtin_function, object,
|
|
|
|
0, NULL, &caught_exception);
|
|
|
|
if (caught_exception) {
|
|
|
|
return Failure::Exception();
|
|
|
|
}
|
|
|
|
return *result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnaryOpStub::UpdateStatus(Handle<Object> object) {
|
|
|
|
State old_state(state_);
|
|
|
|
if (object->IsSmi()) {
|
|
|
|
state_.Add(SMI);
|
|
|
|
if (operation_ == Token::SUB && *object == 0) {
|
|
|
|
// The result (-0) has to be represented as double.
|
|
|
|
state_.Add(HEAP_NUMBER);
|
|
|
|
}
|
|
|
|
} else if (object->IsHeapNumber()) {
|
|
|
|
state_.Add(HEAP_NUMBER);
|
|
|
|
} else {
|
|
|
|
state_.Add(GENERIC);
|
|
|
|
}
|
|
|
|
TraceTransition(old_state, state_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Handle<Type> UnaryOpStub::GetType(Isolate* isolate) {
|
|
|
|
if (state_.Contains(GENERIC)) {
|
|
|
|
return handle(Type::Any(), isolate);
|
|
|
|
}
|
|
|
|
Handle<Type> type = handle(Type::None(), isolate);
|
|
|
|
if (state_.Contains(SMI)) {
|
|
|
|
type = handle(
|
|
|
|
Type::Union(type, handle(Type::Smi(), isolate)), isolate);
|
|
|
|
}
|
|
|
|
if (state_.Contains(HEAP_NUMBER)) {
|
|
|
|
type = handle(
|
|
|
|
Type::Union(type, handle(Type::Double(), isolate)), isolate);
|
|
|
|
}
|
|
|
|
return type;
|
2011-10-03 11:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-14 15:59:45 +00:00
|
|
|
void BinaryOpStub::Generate(MacroAssembler* masm) {
|
|
|
|
// Explicitly allow generation of nested stubs. It is safe here because
|
|
|
|
// generation code does not use any raw pointers.
|
|
|
|
AllowStubCallsScope allow_stub_calls(masm, true);
|
|
|
|
|
|
|
|
BinaryOpIC::TypeInfo operands_type = Max(left_type_, right_type_);
|
|
|
|
if (left_type_ == BinaryOpIC::ODDBALL && right_type_ == BinaryOpIC::ODDBALL) {
|
|
|
|
// The OddballStub handles a number and an oddball, not two oddballs.
|
|
|
|
operands_type = BinaryOpIC::GENERIC;
|
|
|
|
}
|
|
|
|
switch (operands_type) {
|
|
|
|
case BinaryOpIC::UNINITIALIZED:
|
|
|
|
GenerateTypeTransition(masm);
|
|
|
|
break;
|
|
|
|
case BinaryOpIC::SMI:
|
|
|
|
GenerateSmiStub(masm);
|
|
|
|
break;
|
|
|
|
case BinaryOpIC::INT32:
|
|
|
|
GenerateInt32Stub(masm);
|
|
|
|
break;
|
2013-02-28 14:43:57 +00:00
|
|
|
case BinaryOpIC::NUMBER:
|
|
|
|
GenerateNumberStub(masm);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case BinaryOpIC::ODDBALL:
|
|
|
|
GenerateOddballStub(masm);
|
|
|
|
break;
|
|
|
|
case BinaryOpIC::STRING:
|
|
|
|
GenerateStringStub(masm);
|
|
|
|
break;
|
|
|
|
case BinaryOpIC::GENERIC:
|
|
|
|
GenerateGeneric(masm);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define __ ACCESS_MASM(masm)
|
|
|
|
|
|
|
|
|
|
|
|
void BinaryOpStub::GenerateCallRuntime(MacroAssembler* masm) {
|
|
|
|
switch (op_) {
|
|
|
|
case Token::ADD:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::ADD, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::SUB:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::SUB, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::MUL:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::MUL, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::DIV:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::DIV, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::MOD:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::MOD, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::BIT_OR:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::BIT_OR, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::BIT_AND:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::BIT_AND, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::BIT_XOR:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::BIT_XOR, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::SAR:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::SAR, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::SHR:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::SHR, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
case Token::SHL:
|
2013-05-14 15:30:55 +00:00
|
|
|
__ InvokeBuiltin(Builtins::SHL, CALL_FUNCTION);
|
2012-11-14 15:59:45 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#undef __
|
|
|
|
|
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
void UnaryOpStub::PrintBaseName(StringStream* stream) {
|
|
|
|
CodeStub::PrintBaseName(stream);
|
|
|
|
if (operation_ == Token::SUB) stream->Add("Minus");
|
|
|
|
if (operation_ == Token::BIT_NOT) stream->Add("Not");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnaryOpStub::PrintState(StringStream* stream) {
|
|
|
|
state_.Print(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnaryOpStub::State::Print(StringStream* stream) const {
|
|
|
|
stream->Add("(");
|
|
|
|
SimpleListPrinter printer(stream);
|
|
|
|
if (IsEmpty()) printer.Add("None");
|
|
|
|
if (Contains(GENERIC)) printer.Add("Generic");
|
|
|
|
if (Contains(HEAP_NUMBER)) printer.Add("HeapNumber");
|
|
|
|
if (Contains(SMI)) printer.Add("Smi");
|
|
|
|
stream->Add(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-14 15:59:45 +00:00
|
|
|
void BinaryOpStub::PrintName(StringStream* stream) {
|
|
|
|
const char* op_name = Token::Name(op_);
|
|
|
|
const char* overwrite_name;
|
|
|
|
switch (mode_) {
|
|
|
|
case NO_OVERWRITE: overwrite_name = "Alloc"; break;
|
|
|
|
case OVERWRITE_RIGHT: overwrite_name = "OverwriteRight"; break;
|
|
|
|
case OVERWRITE_LEFT: overwrite_name = "OverwriteLeft"; break;
|
|
|
|
default: overwrite_name = "UnknownOverwrite"; break;
|
|
|
|
}
|
|
|
|
stream->Add("BinaryOpStub_%s_%s_%s+%s",
|
|
|
|
op_name,
|
|
|
|
overwrite_name,
|
|
|
|
BinaryOpIC::GetName(left_type_),
|
|
|
|
BinaryOpIC::GetName(right_type_));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BinaryOpStub::GenerateStringStub(MacroAssembler* masm) {
|
|
|
|
ASSERT(left_type_ == BinaryOpIC::STRING || right_type_ == BinaryOpIC::STRING);
|
|
|
|
ASSERT(op_ == Token::ADD);
|
|
|
|
if (left_type_ == BinaryOpIC::STRING && right_type_ == BinaryOpIC::STRING) {
|
|
|
|
GenerateBothStringStub(masm);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Try to add arguments as strings, otherwise, transition to the generic
|
|
|
|
// BinaryOpIC type.
|
|
|
|
GenerateAddStrings(masm);
|
|
|
|
GenerateTypeTransition(masm);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-07 13:11:17 +00:00
|
|
|
InlineCacheState ICCompareStub::GetICState() {
|
|
|
|
CompareIC::State state = Max(left_, right_);
|
|
|
|
switch (state) {
|
|
|
|
case CompareIC::UNINITIALIZED:
|
|
|
|
return ::v8::internal::UNINITIALIZED;
|
|
|
|
case CompareIC::SMI:
|
|
|
|
case CompareIC::NUMBER:
|
|
|
|
case CompareIC::INTERNALIZED_STRING:
|
|
|
|
case CompareIC::STRING:
|
|
|
|
case CompareIC::UNIQUE_NAME:
|
|
|
|
case CompareIC::OBJECT:
|
|
|
|
case CompareIC::KNOWN_OBJECT:
|
|
|
|
return MONOMORPHIC;
|
|
|
|
case CompareIC::GENERIC:
|
|
|
|
return ::v8::internal::GENERIC;
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
return ::v8::internal::UNINITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-09 09:26:14 +00:00
|
|
|
void ICCompareStub::AddToSpecialCache(Handle<Code> new_object) {
|
|
|
|
ASSERT(*known_map_ != NULL);
|
|
|
|
Isolate* isolate = new_object->GetIsolate();
|
|
|
|
Factory* factory = isolate->factory();
|
|
|
|
return Map::UpdateCodeCache(known_map_,
|
2012-08-15 15:08:42 +00:00
|
|
|
strict() ?
|
2013-02-28 17:03:34 +00:00
|
|
|
factory->strict_compare_ic_string() :
|
|
|
|
factory->compare_ic_string(),
|
2011-12-09 09:26:14 +00:00
|
|
|
new_object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-22 07:58:59 +00:00
|
|
|
bool ICCompareStub::FindCodeInSpecialCache(Code** code_out, Isolate* isolate) {
|
2011-12-09 09:26:14 +00:00
|
|
|
Factory* factory = isolate->factory();
|
|
|
|
Code::Flags flags = Code::ComputeFlags(
|
2013-04-18 09:50:46 +00:00
|
|
|
GetCodeKind(),
|
2011-12-09 09:26:14 +00:00
|
|
|
UNINITIALIZED);
|
2012-08-15 15:08:42 +00:00
|
|
|
ASSERT(op_ == Token::EQ || op_ == Token::EQ_STRICT);
|
2013-02-28 17:03:34 +00:00
|
|
|
Handle<Object> probe(
|
|
|
|
known_map_->FindInCodeCache(
|
|
|
|
strict() ?
|
|
|
|
*factory->strict_compare_ic_string() :
|
|
|
|
*factory->compare_ic_string(),
|
|
|
|
flags),
|
|
|
|
isolate);
|
2011-12-09 09:26:14 +00:00
|
|
|
if (probe->IsCode()) {
|
|
|
|
*code_out = Code::cast(*probe);
|
2012-11-14 15:59:45 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
Token::Value cached_op;
|
|
|
|
ICCompareStub::DecodeMinorKey((*code_out)->stub_info(), NULL, NULL, NULL,
|
|
|
|
&cached_op);
|
|
|
|
ASSERT(op_ == cached_op);
|
|
|
|
#endif
|
2011-12-09 09:26:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
int ICCompareStub::MinorKey() {
|
2012-11-14 15:59:45 +00:00
|
|
|
return OpField::encode(op_ - Token::EQ) |
|
|
|
|
LeftStateField::encode(left_) |
|
|
|
|
RightStateField::encode(right_) |
|
|
|
|
HandlerStateField::encode(state_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ICCompareStub::DecodeMinorKey(int minor_key,
|
|
|
|
CompareIC::State* left_state,
|
|
|
|
CompareIC::State* right_state,
|
|
|
|
CompareIC::State* handler_state,
|
|
|
|
Token::Value* op) {
|
|
|
|
if (left_state) {
|
|
|
|
*left_state =
|
|
|
|
static_cast<CompareIC::State>(LeftStateField::decode(minor_key));
|
|
|
|
}
|
|
|
|
if (right_state) {
|
|
|
|
*right_state =
|
|
|
|
static_cast<CompareIC::State>(RightStateField::decode(minor_key));
|
|
|
|
}
|
|
|
|
if (handler_state) {
|
|
|
|
*handler_state =
|
|
|
|
static_cast<CompareIC::State>(HandlerStateField::decode(minor_key));
|
|
|
|
}
|
|
|
|
if (op) {
|
|
|
|
*op = static_cast<Token::Value>(OpField::decode(minor_key) + Token::EQ);
|
|
|
|
}
|
2010-12-07 11:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ICCompareStub::Generate(MacroAssembler* masm) {
|
|
|
|
switch (state_) {
|
|
|
|
case CompareIC::UNINITIALIZED:
|
|
|
|
GenerateMiss(masm);
|
|
|
|
break;
|
2012-11-14 15:59:45 +00:00
|
|
|
case CompareIC::SMI:
|
2010-12-07 11:31:57 +00:00
|
|
|
GenerateSmis(masm);
|
|
|
|
break;
|
2013-02-28 14:43:57 +00:00
|
|
|
case CompareIC::NUMBER:
|
|
|
|
GenerateNumbers(masm);
|
2010-12-07 11:31:57 +00:00
|
|
|
break;
|
2012-11-14 15:59:45 +00:00
|
|
|
case CompareIC::STRING:
|
2011-05-04 18:30:37 +00:00
|
|
|
GenerateStrings(masm);
|
|
|
|
break;
|
2013-02-28 17:03:34 +00:00
|
|
|
case CompareIC::INTERNALIZED_STRING:
|
|
|
|
GenerateInternalizedStrings(masm);
|
2011-05-09 13:30:04 +00:00
|
|
|
break;
|
2013-03-01 13:28:55 +00:00
|
|
|
case CompareIC::UNIQUE_NAME:
|
|
|
|
GenerateUniqueNames(masm);
|
|
|
|
break;
|
2012-11-14 15:59:45 +00:00
|
|
|
case CompareIC::OBJECT:
|
2010-12-07 11:31:57 +00:00
|
|
|
GenerateObjects(masm);
|
|
|
|
break;
|
2013-02-28 14:43:57 +00:00
|
|
|
case CompareIC::KNOWN_OBJECT:
|
2011-12-09 09:26:14 +00:00
|
|
|
ASSERT(*known_map_ != NULL);
|
|
|
|
GenerateKnownObjects(masm);
|
|
|
|
break;
|
2012-11-14 15:59:45 +00:00
|
|
|
case CompareIC::GENERIC:
|
|
|
|
GenerateGeneric(masm);
|
|
|
|
break;
|
2010-12-07 11:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
void CompareNilICStub::UpdateStatus(Handle<Object> object) {
|
2013-06-12 17:20:37 +00:00
|
|
|
ASSERT(state_ != State::Generic());
|
2013-07-05 09:26:22 +00:00
|
|
|
State old_state(state_);
|
2013-06-10 15:47:23 +00:00
|
|
|
if (object->IsNull()) {
|
2013-06-12 17:20:37 +00:00
|
|
|
state_.Add(NULL_TYPE);
|
2013-06-10 15:47:23 +00:00
|
|
|
} else if (object->IsUndefined()) {
|
2013-06-12 17:20:37 +00:00
|
|
|
state_.Add(UNDEFINED);
|
2013-06-10 15:47:23 +00:00
|
|
|
} else if (object->IsUndetectableObject() ||
|
|
|
|
object->IsOddball() ||
|
|
|
|
!object->IsHeapObject()) {
|
2013-06-12 17:20:37 +00:00
|
|
|
state_ = State::Generic();
|
2013-06-10 15:47:23 +00:00
|
|
|
} else if (IsMonomorphic()) {
|
2013-06-12 17:20:37 +00:00
|
|
|
state_ = State::Generic();
|
2013-04-24 11:32:17 +00:00
|
|
|
} else {
|
2013-06-12 17:20:37 +00:00
|
|
|
state_.Add(MONOMORPHIC_MAP);
|
2013-04-24 11:32:17 +00:00
|
|
|
}
|
2013-07-05 09:26:22 +00:00
|
|
|
TraceTransition(old_state, state_);
|
2013-05-16 10:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
template<class StateType>
|
|
|
|
void HydrogenCodeStub::TraceTransition(StateType from, StateType to) {
|
2013-05-24 15:20:48 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (!FLAG_trace_ic) return;
|
|
|
|
char buffer[100];
|
|
|
|
NoAllocationStringAllocator allocator(buffer,
|
|
|
|
static_cast<unsigned>(sizeof(buffer)));
|
|
|
|
StringStream stream(&allocator);
|
2013-07-05 09:26:22 +00:00
|
|
|
stream.Add("[");
|
|
|
|
PrintBaseName(&stream);
|
|
|
|
stream.Add(": ");
|
|
|
|
from.Print(&stream);
|
2013-05-24 15:20:48 +00:00
|
|
|
stream.Add("=>");
|
|
|
|
to.Print(&stream);
|
|
|
|
stream.Add("]\n");
|
|
|
|
stream.OutputToStdOut();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-07-05 09:52:11 +00:00
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
void CompareNilICStub::PrintBaseName(StringStream* stream) {
|
|
|
|
CodeStub::PrintBaseName(stream);
|
|
|
|
stream->Add((nil_value_ == kNullValue) ? "(NullValue)":
|
|
|
|
"(UndefinedValue)");
|
|
|
|
}
|
2013-05-24 15:20:48 +00:00
|
|
|
|
2013-07-05 09:52:11 +00:00
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
void CompareNilICStub::PrintState(StringStream* stream) {
|
2013-06-12 17:20:37 +00:00
|
|
|
state_.Print(stream);
|
2013-05-16 10:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-12 17:20:37 +00:00
|
|
|
void CompareNilICStub::State::Print(StringStream* stream) const {
|
2013-05-16 10:59:17 +00:00
|
|
|
stream->Add("(");
|
|
|
|
SimpleListPrinter printer(stream);
|
|
|
|
if (IsEmpty()) printer.Add("None");
|
|
|
|
if (Contains(UNDEFINED)) printer.Add("Undefined");
|
|
|
|
if (Contains(NULL_TYPE)) printer.Add("Null");
|
|
|
|
if (Contains(MONOMORPHIC_MAP)) printer.Add("MonomorphicMap");
|
|
|
|
if (Contains(UNDETECTABLE)) printer.Add("Undetectable");
|
2013-06-12 17:20:37 +00:00
|
|
|
if (Contains(GENERIC)) printer.Add("Generic");
|
2013-05-16 10:59:17 +00:00
|
|
|
stream->Add(")");
|
2013-04-24 11:32:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-12 17:20:37 +00:00
|
|
|
Handle<Type> CompareNilICStub::StateToType(
|
|
|
|
Isolate* isolate,
|
|
|
|
State state,
|
|
|
|
Handle<Map> map) {
|
|
|
|
if (state.Contains(CompareNilICStub::GENERIC)) {
|
|
|
|
return handle(Type::Any(), isolate);
|
|
|
|
}
|
|
|
|
|
|
|
|
Handle<Type> result(Type::None(), isolate);
|
|
|
|
if (state.Contains(CompareNilICStub::UNDEFINED)) {
|
|
|
|
result = handle(Type::Union(result, handle(Type::Undefined(), isolate)),
|
|
|
|
isolate);
|
|
|
|
}
|
|
|
|
if (state.Contains(CompareNilICStub::NULL_TYPE)) {
|
|
|
|
result = handle(Type::Union(result, handle(Type::Null(), isolate)),
|
|
|
|
isolate);
|
|
|
|
}
|
|
|
|
if (state.Contains(CompareNilICStub::UNDETECTABLE)) {
|
|
|
|
result = handle(Type::Union(result, handle(Type::Undetectable(), isolate)),
|
|
|
|
isolate);
|
|
|
|
} else if (state.Contains(CompareNilICStub::MONOMORPHIC_MAP)) {
|
|
|
|
Type* type = map.is_null() ? Type::Detectable() : Type::Class(map);
|
|
|
|
result = handle(Type::Union(result, handle(type, isolate)), isolate);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-13 11:08:25 +00:00
|
|
|
void InstanceofStub::PrintName(StringStream* stream) {
|
2011-01-05 12:01:53 +00:00
|
|
|
const char* args = "";
|
|
|
|
if (HasArgsInRegisters()) {
|
|
|
|
args = "_REGS";
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* inline_check = "";
|
|
|
|
if (HasCallSiteInlineCheck()) {
|
|
|
|
inline_check = "_INLINE";
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* return_true_false_object = "";
|
|
|
|
if (ReturnTrueFalseObject()) {
|
|
|
|
return_true_false_object = "_TRUEFALSE";
|
|
|
|
}
|
|
|
|
|
2011-07-13 11:08:25 +00:00
|
|
|
stream->Add("InstanceofStub%s%s%s",
|
|
|
|
args,
|
|
|
|
inline_check,
|
|
|
|
return_true_false_object);
|
2011-01-05 12:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-11 13:48:14 +00:00
|
|
|
void JSEntryStub::FinishCode(Handle<Code> code) {
|
|
|
|
Handle<FixedArray> handler_table =
|
|
|
|
code->GetIsolate()->factory()->NewFixedArray(1, TENURED);
|
|
|
|
handler_table->set(0, Smi::FromInt(handler_offset_));
|
|
|
|
code->set_handler_table(*handler_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
void KeyedLoadDictionaryElementStub::Generate(MacroAssembler* masm) {
|
|
|
|
KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm);
|
2011-05-18 13:17:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-08 10:02:16 +00:00
|
|
|
void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) {
|
|
|
|
CreateAllocationSiteStub stub;
|
|
|
|
stub.GetCode(isolate)->set_is_pregenerated(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-08 10:46:10 +00:00
|
|
|
void KeyedStoreElementStub::Generate(MacroAssembler* masm) {
|
|
|
|
switch (elements_kind_) {
|
2011-09-09 09:35:57 +00:00
|
|
|
case FAST_ELEMENTS:
|
2012-05-23 14:24:29 +00:00
|
|
|
case FAST_HOLEY_ELEMENTS:
|
|
|
|
case FAST_SMI_ELEMENTS:
|
|
|
|
case FAST_HOLEY_SMI_ELEMENTS: {
|
2011-09-22 11:30:04 +00:00
|
|
|
KeyedStoreStubCompiler::GenerateStoreFastElement(masm,
|
|
|
|
is_js_array_,
|
2012-02-10 12:36:05 +00:00
|
|
|
elements_kind_,
|
2013-03-06 21:51:07 +00:00
|
|
|
store_mode_);
|
2011-09-22 11:30:04 +00:00
|
|
|
}
|
2011-07-08 10:46:10 +00:00
|
|
|
break;
|
2011-09-09 09:35:57 +00:00
|
|
|
case FAST_DOUBLE_ELEMENTS:
|
2012-05-23 14:24:29 +00:00
|
|
|
case FAST_HOLEY_DOUBLE_ELEMENTS:
|
2011-07-13 13:50:27 +00:00
|
|
|
KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm,
|
2012-02-10 12:36:05 +00:00
|
|
|
is_js_array_,
|
2013-03-06 21:51:07 +00:00
|
|
|
store_mode_);
|
2011-07-08 10:46:10 +00:00
|
|
|
break;
|
2011-09-09 09:35:57 +00:00
|
|
|
case EXTERNAL_BYTE_ELEMENTS:
|
|
|
|
case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
|
|
|
|
case EXTERNAL_SHORT_ELEMENTS:
|
|
|
|
case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
|
|
|
|
case EXTERNAL_INT_ELEMENTS:
|
|
|
|
case EXTERNAL_UNSIGNED_INT_ELEMENTS:
|
|
|
|
case EXTERNAL_FLOAT_ELEMENTS:
|
|
|
|
case EXTERNAL_DOUBLE_ELEMENTS:
|
|
|
|
case EXTERNAL_PIXEL_ELEMENTS:
|
2011-07-08 10:46:10 +00:00
|
|
|
KeyedStoreStubCompiler::GenerateStoreExternalArray(masm, elements_kind_);
|
|
|
|
break;
|
2011-09-09 09:35:57 +00:00
|
|
|
case DICTIONARY_ELEMENTS:
|
2011-07-08 10:46:10 +00:00
|
|
|
KeyedStoreStubCompiler::GenerateStoreDictionaryElement(masm);
|
|
|
|
break;
|
2011-09-09 09:35:57 +00:00
|
|
|
case NON_STRICT_ARGUMENTS_ELEMENTS:
|
2011-07-08 10:46:10 +00:00
|
|
|
UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
2011-05-18 13:17:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-13 11:08:25 +00:00
|
|
|
void ArgumentsAccessStub::PrintName(StringStream* stream) {
|
2011-09-27 11:42:02 +00:00
|
|
|
stream->Add("ArgumentsAccessStub_");
|
2011-07-13 11:08:25 +00:00
|
|
|
switch (type_) {
|
2011-09-27 11:42:02 +00:00
|
|
|
case READ_ELEMENT: stream->Add("ReadElement"); break;
|
|
|
|
case NEW_NON_STRICT_FAST: stream->Add("NewNonStrictFast"); break;
|
|
|
|
case NEW_NON_STRICT_SLOW: stream->Add("NewNonStrictSlow"); break;
|
|
|
|
case NEW_STRICT: stream->Add("NewStrict"); break;
|
2011-07-13 11:08:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CallFunctionStub::PrintName(StringStream* stream) {
|
2011-09-27 11:42:02 +00:00
|
|
|
stream->Add("CallFunctionStub_Args%d", argc_);
|
|
|
|
if (ReceiverMightBeImplicit()) stream->Add("_Implicit");
|
|
|
|
if (RecordCallTarget()) stream->Add("_Recording");
|
2011-07-13 11:08:25 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 13:51:04 +00:00
|
|
|
|
2012-01-27 13:03:19 +00:00
|
|
|
void CallConstructStub::PrintName(StringStream* stream) {
|
|
|
|
stream->Add("CallConstructStub");
|
|
|
|
if (RecordCallTarget()) stream->Add("_Recording");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
bool ToBooleanStub::UpdateStatus(Handle<Object> object) {
|
2013-05-29 14:49:28 +00:00
|
|
|
Types old_types(types_);
|
2013-07-05 09:26:22 +00:00
|
|
|
bool to_boolean_value = types_.UpdateStatus(object);
|
|
|
|
TraceTransition(old_types, types_);
|
2013-05-29 14:49:28 +00:00
|
|
|
return to_boolean_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
void ToBooleanStub::PrintState(StringStream* stream) {
|
2011-07-21 13:51:04 +00:00
|
|
|
types_.Print(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-28 13:33:51 +00:00
|
|
|
void ToBooleanStub::Types::Print(StringStream* stream) const {
|
2013-05-16 10:59:17 +00:00
|
|
|
stream->Add("(");
|
|
|
|
SimpleListPrinter printer(stream);
|
|
|
|
if (IsEmpty()) printer.Add("None");
|
|
|
|
if (Contains(UNDEFINED)) printer.Add("Undefined");
|
|
|
|
if (Contains(BOOLEAN)) printer.Add("Bool");
|
|
|
|
if (Contains(NULL_TYPE)) printer.Add("Null");
|
|
|
|
if (Contains(SMI)) printer.Add("Smi");
|
|
|
|
if (Contains(SPEC_OBJECT)) printer.Add("SpecObject");
|
|
|
|
if (Contains(STRING)) printer.Add("String");
|
|
|
|
if (Contains(SYMBOL)) printer.Add("Symbol");
|
|
|
|
if (Contains(HEAP_NUMBER)) printer.Add("HeapNumber");
|
|
|
|
stream->Add(")");
|
2011-07-21 13:51:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
bool ToBooleanStub::Types::UpdateStatus(Handle<Object> object) {
|
2011-07-21 13:51:04 +00:00
|
|
|
if (object->IsUndefined()) {
|
|
|
|
Add(UNDEFINED);
|
|
|
|
return false;
|
|
|
|
} else if (object->IsBoolean()) {
|
|
|
|
Add(BOOLEAN);
|
|
|
|
return object->IsTrue();
|
|
|
|
} else if (object->IsNull()) {
|
|
|
|
Add(NULL_TYPE);
|
|
|
|
return false;
|
|
|
|
} else if (object->IsSmi()) {
|
|
|
|
Add(SMI);
|
|
|
|
return Smi::cast(*object)->value() != 0;
|
|
|
|
} else if (object->IsSpecObject()) {
|
|
|
|
Add(SPEC_OBJECT);
|
2011-07-22 12:42:40 +00:00
|
|
|
return !object->IsUndetectableObject();
|
2011-07-21 13:51:04 +00:00
|
|
|
} else if (object->IsString()) {
|
|
|
|
Add(STRING);
|
2011-07-22 12:42:40 +00:00
|
|
|
return !object->IsUndetectableObject() &&
|
|
|
|
String::cast(*object)->length() != 0;
|
2013-03-22 16:33:50 +00:00
|
|
|
} else if (object->IsSymbol()) {
|
|
|
|
Add(SYMBOL);
|
|
|
|
return true;
|
2011-07-21 13:51:04 +00:00
|
|
|
} else if (object->IsHeapNumber()) {
|
2011-08-11 07:22:16 +00:00
|
|
|
ASSERT(!object->IsUndetectableObject());
|
2011-07-21 13:51:04 +00:00
|
|
|
Add(HEAP_NUMBER);
|
|
|
|
double value = HeapNumber::cast(*object)->value();
|
2013-04-19 13:26:47 +00:00
|
|
|
return value != 0 && !std::isnan(value);
|
2011-07-21 13:51:04 +00:00
|
|
|
} else {
|
2011-08-11 07:22:16 +00:00
|
|
|
// We should never see an internal object at runtime here!
|
|
|
|
UNREACHABLE();
|
|
|
|
return true;
|
2011-07-21 13:51:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-28 13:33:51 +00:00
|
|
|
bool ToBooleanStub::Types::NeedsMap() const {
|
|
|
|
return Contains(ToBooleanStub::SPEC_OBJECT)
|
|
|
|
|| Contains(ToBooleanStub::STRING)
|
2013-03-22 16:33:50 +00:00
|
|
|
|| Contains(ToBooleanStub::SYMBOL)
|
2011-08-11 07:22:16 +00:00
|
|
|
|| Contains(ToBooleanStub::HEAP_NUMBER);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ToBooleanStub::Types::CanBeUndetectable() const {
|
|
|
|
return Contains(ToBooleanStub::SPEC_OBJECT)
|
|
|
|
|| Contains(ToBooleanStub::STRING);
|
2011-07-28 13:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-27 12:33:24 +00:00
|
|
|
void StubFailureTrampolineStub::GenerateAheadOfTime(Isolate* isolate) {
|
2013-04-04 17:55:43 +00:00
|
|
|
StubFailureTrampolineStub stub1(NOT_JS_FUNCTION_STUB_MODE);
|
|
|
|
StubFailureTrampolineStub stub2(JS_FUNCTION_STUB_MODE);
|
|
|
|
stub1.GetCode(isolate)->set_is_pregenerated(true);
|
|
|
|
stub2.GetCode(isolate)->set_is_pregenerated(true);
|
2013-02-05 08:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-17 15:18:15 +00:00
|
|
|
void ProfileEntryHookStub::EntryHookTrampoline(intptr_t function,
|
|
|
|
intptr_t stack_pointer) {
|
2013-06-28 13:40:41 +00:00
|
|
|
FunctionEntryHook entry_hook = Isolate::Current()->function_entry_hook();
|
|
|
|
ASSERT(entry_hook != NULL);
|
|
|
|
entry_hook(function, stack_pointer);
|
2012-07-17 15:18:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-25 16:00:32 +00:00
|
|
|
static void InstallDescriptor(Isolate* isolate, HydrogenCodeStub* stub) {
|
|
|
|
int major_key = stub->MajorKey();
|
|
|
|
CodeStubInterfaceDescriptor* descriptor =
|
|
|
|
isolate->code_stub_interface_descriptor(major_key);
|
|
|
|
if (!descriptor->initialized()) {
|
|
|
|
stub->InitializeInterfaceDescriptor(isolate, descriptor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ArrayConstructorStubBase::InstallDescriptors(Isolate* isolate) {
|
|
|
|
ArrayNoArgumentConstructorStub stub1(GetInitialFastElementsKind());
|
|
|
|
InstallDescriptor(isolate, &stub1);
|
|
|
|
ArraySingleArgumentConstructorStub stub2(GetInitialFastElementsKind());
|
|
|
|
InstallDescriptor(isolate, &stub2);
|
|
|
|
ArrayNArgumentsConstructorStub stub3(GetInitialFastElementsKind());
|
|
|
|
InstallDescriptor(isolate, &stub3);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate)
|
|
|
|
: argument_count_(ANY) {
|
|
|
|
ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate,
|
|
|
|
int argument_count) {
|
|
|
|
if (argument_count == 0) {
|
|
|
|
argument_count_ = NONE;
|
|
|
|
} else if (argument_count == 1) {
|
|
|
|
argument_count_ = ONE;
|
|
|
|
} else if (argument_count >= 2) {
|
|
|
|
argument_count_ = MORE_THAN_ONE;
|
|
|
|
} else {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-05 10:43:18 +00:00
|
|
|
void InternalArrayConstructorStubBase::InstallDescriptors(Isolate* isolate) {
|
|
|
|
InternalArrayNoArgumentConstructorStub stub1(FAST_ELEMENTS);
|
|
|
|
InstallDescriptor(isolate, &stub1);
|
|
|
|
InternalArraySingleArgumentConstructorStub stub2(FAST_ELEMENTS);
|
|
|
|
InstallDescriptor(isolate, &stub2);
|
|
|
|
InternalArrayNArgumentsConstructorStub stub3(FAST_ELEMENTS);
|
|
|
|
InstallDescriptor(isolate, &stub3);
|
|
|
|
}
|
|
|
|
|
|
|
|
InternalArrayConstructorStub::InternalArrayConstructorStub(
|
|
|
|
Isolate* isolate) {
|
|
|
|
InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
} } // namespace v8::internal
|