2014-09-11 13:18:58 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "src/v8.h"
|
|
|
|
|
|
|
|
#include "src/bootstrapper.h"
|
|
|
|
#include "src/code-factory.h"
|
|
|
|
#include "src/ic/ic.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2015-03-02 13:36:38 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::LoadGlobalIC(Isolate* isolate,
|
|
|
|
Handle<GlobalObject> global,
|
|
|
|
Handle<String> name) {
|
|
|
|
return Callable(LoadIC::load_global(isolate, global, name),
|
|
|
|
LoadDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::LoadIC(Isolate* isolate, ContextualMode mode) {
|
|
|
|
return Callable(
|
2014-09-16 12:51:33 +00:00
|
|
|
LoadIC::initialize_stub(isolate, LoadICState(mode).GetExtraICState()),
|
2014-09-11 13:18:58 +00:00
|
|
|
LoadDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-10 09:49:43 +00:00
|
|
|
// static
|
2015-02-23 12:34:07 +00:00
|
|
|
Callable CodeFactory::LoadICInOptimizedCode(
|
|
|
|
Isolate* isolate, ContextualMode mode,
|
|
|
|
InlineCacheState initialization_state) {
|
|
|
|
auto code = LoadIC::initialize_stub_in_optimized_code(
|
|
|
|
isolate, LoadICState(mode).GetExtraICState(), initialization_state);
|
2014-10-10 09:49:43 +00:00
|
|
|
if (FLAG_vector_ics) {
|
2015-02-23 12:34:07 +00:00
|
|
|
return Callable(code, VectorLoadICDescriptor(isolate));
|
2014-10-10 09:49:43 +00:00
|
|
|
}
|
2015-02-23 12:34:07 +00:00
|
|
|
return Callable(code, LoadDescriptor(isolate));
|
2014-10-10 09:49:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::KeyedLoadIC(Isolate* isolate) {
|
2014-10-10 09:49:43 +00:00
|
|
|
return Callable(KeyedLoadIC::initialize_stub(isolate),
|
2014-09-11 13:18:58 +00:00
|
|
|
LoadDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-10 09:49:43 +00:00
|
|
|
// static
|
2015-02-25 19:32:36 +00:00
|
|
|
Callable CodeFactory::KeyedLoadICInOptimizedCode(
|
|
|
|
Isolate* isolate, InlineCacheState initialization_state) {
|
|
|
|
auto code = KeyedLoadIC::initialize_stub_in_optimized_code(
|
|
|
|
isolate, initialization_state);
|
2015-04-15 02:35:39 +00:00
|
|
|
if (FLAG_vector_ics && initialization_state != MEGAMORPHIC) {
|
2015-02-25 19:32:36 +00:00
|
|
|
return Callable(code, VectorLoadICDescriptor(isolate));
|
2014-10-10 09:49:43 +00:00
|
|
|
}
|
2015-02-25 19:32:36 +00:00
|
|
|
return Callable(code, LoadDescriptor(isolate));
|
2014-10-10 09:49:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 11:23:51 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::CallIC(Isolate* isolate, int argc,
|
|
|
|
CallICState::CallType call_type) {
|
|
|
|
return Callable(CallIC::initialize_stub(isolate, argc, call_type),
|
|
|
|
CallFunctionWithFeedbackDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::CallICInOptimizedCode(Isolate* isolate, int argc,
|
|
|
|
CallICState::CallType call_type) {
|
|
|
|
return Callable(
|
|
|
|
CallIC::initialize_stub_in_optimized_code(isolate, argc, call_type),
|
|
|
|
CallFunctionWithFeedbackAndVectorDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
2015-02-04 09:34:05 +00:00
|
|
|
Callable CodeFactory::StoreIC(Isolate* isolate, LanguageMode language_mode) {
|
2015-02-23 12:34:07 +00:00
|
|
|
return Callable(
|
|
|
|
StoreIC::initialize_stub(isolate, language_mode, UNINITIALIZED),
|
|
|
|
StoreDescriptor(isolate));
|
2014-09-11 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
2015-02-04 09:34:05 +00:00
|
|
|
Callable CodeFactory::KeyedStoreIC(Isolate* isolate,
|
|
|
|
LanguageMode language_mode) {
|
2015-02-25 19:32:36 +00:00
|
|
|
return Callable(
|
|
|
|
KeyedStoreIC::initialize_stub(isolate, language_mode, UNINITIALIZED),
|
|
|
|
StoreDescriptor(isolate));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::KeyedStoreICInOptimizedCode(
|
|
|
|
Isolate* isolate, LanguageMode language_mode,
|
|
|
|
InlineCacheState initialization_state) {
|
|
|
|
return Callable(KeyedStoreIC::initialize_stub(isolate, language_mode,
|
|
|
|
initialization_state),
|
|
|
|
StoreDescriptor(isolate));
|
2014-09-11 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) {
|
|
|
|
Handle<Code> code = CompareIC::GetUninitialized(isolate, op);
|
2015-03-19 13:09:26 +00:00
|
|
|
return Callable(code, CompareDescriptor(isolate));
|
2014-09-11 13:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
2015-02-05 10:38:41 +00:00
|
|
|
Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) {
|
|
|
|
BinaryOpICStub stub(isolate, op);
|
2014-09-11 13:18:58 +00:00
|
|
|
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::ToBoolean(Isolate* isolate,
|
|
|
|
ToBooleanStub::ResultMode mode,
|
|
|
|
ToBooleanStub::Types types) {
|
|
|
|
ToBooleanStub stub(isolate, mode, types);
|
|
|
|
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::ToNumber(Isolate* isolate) {
|
|
|
|
ToNumberStub stub(isolate);
|
|
|
|
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags,
|
|
|
|
PretenureFlag pretenure_flag) {
|
|
|
|
StringAddStub stub(isolate, flags, pretenure_flag);
|
|
|
|
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-04 12:58:17 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) {
|
|
|
|
AllocateHeapNumberStub stub(isolate);
|
|
|
|
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
// static
|
|
|
|
Callable CodeFactory::CallFunction(Isolate* isolate, int argc,
|
|
|
|
CallFunctionFlags flags) {
|
|
|
|
CallFunctionStub stub(isolate, argc, flags);
|
|
|
|
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|