2014-09-11 13:18:58 +00:00
|
|
|
// Copyright 2012 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.
|
|
|
|
|
|
|
|
#ifndef V8_CODE_FACTORY_H_
|
|
|
|
#define V8_CODE_FACTORY_H_
|
|
|
|
|
|
|
|
#include "src/allocation.h"
|
|
|
|
#include "src/assembler.h"
|
|
|
|
#include "src/codegen.h"
|
|
|
|
#include "src/globals.h"
|
|
|
|
#include "src/interface-descriptors.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// Associates a body of code with an interface descriptor.
|
2015-04-20 13:08:11 +00:00
|
|
|
class Callable final BASE_EMBEDDED {
|
2014-09-11 13:18:58 +00:00
|
|
|
public:
|
|
|
|
Callable(Handle<Code> code, CallInterfaceDescriptor descriptor)
|
|
|
|
: code_(code), descriptor_(descriptor) {}
|
|
|
|
|
|
|
|
Handle<Code> code() const { return code_; }
|
|
|
|
CallInterfaceDescriptor descriptor() const { return descriptor_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Handle<Code> code_;
|
|
|
|
const CallInterfaceDescriptor descriptor_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
class CodeFactory final {
|
2014-09-11 13:18:58 +00:00
|
|
|
public:
|
|
|
|
// Initial states for ICs.
|
2015-07-13 13:39:26 +00:00
|
|
|
static Callable LoadIC(Isolate* isolate, TypeofMode typeof_mode,
|
2015-06-30 15:24:27 +00:00
|
|
|
LanguageMode language_mode);
|
2015-07-13 13:39:26 +00:00
|
|
|
static Callable LoadICInOptimizedCode(Isolate* isolate,
|
|
|
|
TypeofMode typeof_mode,
|
2015-06-30 15:24:27 +00:00
|
|
|
LanguageMode language_mode,
|
2015-02-23 12:34:07 +00:00
|
|
|
InlineCacheState initialization_state);
|
2015-06-30 15:24:27 +00:00
|
|
|
static Callable KeyedLoadIC(Isolate* isolate, LanguageMode language_mode);
|
2015-02-25 19:32:36 +00:00
|
|
|
static Callable KeyedLoadICInOptimizedCode(
|
2015-06-30 15:24:27 +00:00
|
|
|
Isolate* isolate, LanguageMode language_mode,
|
|
|
|
InlineCacheState initialization_state);
|
2015-11-09 08:47:59 +00:00
|
|
|
static Callable CallIC(Isolate* isolate, int argc,
|
|
|
|
ConvertReceiverMode mode = ConvertReceiverMode::kAny);
|
|
|
|
static Callable CallICInOptimizedCode(
|
|
|
|
Isolate* isolate, int argc,
|
|
|
|
ConvertReceiverMode mode = ConvertReceiverMode::kAny);
|
2015-02-04 09:34:05 +00:00
|
|
|
static Callable StoreIC(Isolate* isolate, LanguageMode mode);
|
2015-06-26 07:53:21 +00:00
|
|
|
static Callable StoreICInOptimizedCode(Isolate* isolate, LanguageMode mode,
|
|
|
|
InlineCacheState initialization_state);
|
2015-02-04 09:34:05 +00:00
|
|
|
static Callable KeyedStoreIC(Isolate* isolate, LanguageMode mode);
|
2015-02-25 19:32:36 +00:00
|
|
|
static Callable KeyedStoreICInOptimizedCode(
|
|
|
|
Isolate* isolate, LanguageMode mode,
|
|
|
|
InlineCacheState initialization_state);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2015-05-12 15:23:53 +00:00
|
|
|
static Callable CompareIC(Isolate* isolate, Token::Value op,
|
2015-06-08 12:17:58 +00:00
|
|
|
Strength strength);
|
2015-10-27 11:21:23 +00:00
|
|
|
static Callable CompareNilIC(Isolate* isolate, NilValue nil_value);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2015-04-24 12:32:56 +00:00
|
|
|
static Callable BinaryOpIC(Isolate* isolate, Token::Value op,
|
2015-06-08 12:17:58 +00:00
|
|
|
Strength strength);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
|
|
|
// Code stubs. Add methods here as needed to reduce dependency on
|
|
|
|
// code-stubs.h.
|
2015-08-25 04:48:36 +00:00
|
|
|
static Callable InstanceOf(Isolate* isolate);
|
2015-06-22 12:15:55 +00:00
|
|
|
|
2015-12-02 15:21:47 +00:00
|
|
|
static Callable ToBoolean(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
|
|
|
static Callable ToNumber(Isolate* isolate);
|
2015-08-28 12:59:51 +00:00
|
|
|
static Callable ToString(Isolate* isolate);
|
2015-10-19 08:35:00 +00:00
|
|
|
static Callable ToLength(Isolate* isolate);
|
2015-07-31 12:25:28 +00:00
|
|
|
static Callable ToObject(Isolate* isolate);
|
2015-10-19 11:59:24 +00:00
|
|
|
static Callable NumberToString(Isolate* isolate);
|
|
|
|
|
|
|
|
static Callable RegExpConstructResult(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
|
|
|
static Callable StringAdd(Isolate* isolate, StringAddFlags flags,
|
|
|
|
PretenureFlag pretenure_flag);
|
2015-09-18 08:30:22 +00:00
|
|
|
static Callable StringCompare(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
|
2015-05-06 13:31:00 +00:00
|
|
|
static Callable Typeof(Isolate* isolate);
|
|
|
|
|
2015-11-25 09:22:39 +00:00
|
|
|
static Callable FastCloneRegExp(Isolate* isolate);
|
2015-04-21 15:43:31 +00:00
|
|
|
static Callable FastCloneShallowArray(Isolate* isolate);
|
|
|
|
static Callable FastCloneShallowObject(Isolate* isolate, int length);
|
|
|
|
|
2015-10-02 09:30:15 +00:00
|
|
|
static Callable FastNewContext(Isolate* isolate, int slot_count);
|
2015-04-27 09:08:20 +00:00
|
|
|
static Callable FastNewClosure(Isolate* isolate, LanguageMode language_mode,
|
|
|
|
FunctionKind kind);
|
|
|
|
|
2015-09-24 15:30:30 +00:00
|
|
|
static Callable ArgumentsAccess(Isolate* isolate, bool is_unmapped_arguments,
|
|
|
|
bool has_duplicate_parameters);
|
|
|
|
|
2014-11-04 12:58:17 +00:00
|
|
|
static Callable AllocateHeapNumber(Isolate* isolate);
|
2015-10-30 16:11:54 +00:00
|
|
|
static Callable AllocateMutableHeapNumber(Isolate* isolate);
|
2015-10-16 08:40:02 +00:00
|
|
|
static Callable AllocateInNewSpace(Isolate* isolate);
|
2014-11-04 12:58:17 +00:00
|
|
|
|
2015-11-04 11:53:08 +00:00
|
|
|
static Callable ArgumentAdaptor(Isolate* isolate);
|
2015-11-09 08:47:59 +00:00
|
|
|
static Callable Call(Isolate* isolate,
|
|
|
|
ConvertReceiverMode mode = ConvertReceiverMode::kAny);
|
|
|
|
static Callable CallFunction(
|
|
|
|
Isolate* isolate, ConvertReceiverMode mode = ConvertReceiverMode::kAny);
|
2015-11-23 10:34:04 +00:00
|
|
|
static Callable Construct(Isolate* isolate);
|
2015-11-04 11:53:08 +00:00
|
|
|
|
2015-10-02 18:13:41 +00:00
|
|
|
static Callable InterpreterPushArgsAndCall(Isolate* isolate);
|
2015-10-15 16:46:16 +00:00
|
|
|
static Callable InterpreterPushArgsAndConstruct(Isolate* isolate);
|
2015-10-02 18:13:41 +00:00
|
|
|
static Callable InterpreterCEntry(Isolate* isolate);
|
2014-09-11 13:18:58 +00:00
|
|
|
};
|
2014-11-04 12:58:17 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
2014-09-11 13:18:58 +00:00
|
|
|
#endif // V8_CODE_FACTORY_H_
|