Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: src/api-arguments.h

Issue 1776353002: Split off api-arguments.[h|cc] from arguments.[h|cc] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « BUILD.gn ('k') | src/api-arguments.cc » ('j') | src/arm/code-stubs-arm.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api-arguments.h
diff --git a/src/arguments.h b/src/api-arguments.h
similarity index 59%
copy from src/arguments.h
copy to src/api-arguments.h
index d781d8a353f40dde744b302672e72b98fa5eb00c..858404975877a50d33461f55b5a1e255974d1c80 100644
--- a/src/arguments.h
+++ b/src/api-arguments.h
@@ -1,77 +1,16 @@
-// Copyright 2012 the V8 project authors. All rights reserved.
+// Copyright 2016 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_ARGUMENTS_H_
-#define V8_ARGUMENTS_H_
+#ifndef V8_API_ARGUMENTS_H_
+#define V8_API_ARGUMENTS_H_
-#include "src/allocation.h"
#include "src/isolate.h"
#include "src/tracing/trace-event.h"
namespace v8 {
namespace internal {
-// Arguments provides access to runtime call parameters.
-//
-// It uses the fact that the instance fields of Arguments
-// (length_, arguments_) are "overlayed" with the parameters
-// (no. of parameters, and the parameter pointer) passed so
-// that inside the C++ function, the parameters passed can
-// be accessed conveniently:
-//
-// Object* Runtime_function(Arguments args) {
-// ... use args[i] here ...
-// }
-//
-// Note that length_ (whose value is in the integer range) is defined
-// as intptr_t to provide endian-neutrality on 64-bit archs.
-
-class Arguments BASE_EMBEDDED {
- public:
- Arguments(int length, Object** arguments)
- : length_(length), arguments_(arguments) {
- DCHECK_GE(length_, 0);
- }
-
- Object*& operator[] (int index) {
- DCHECK_GE(index, 0);
- DCHECK_LT(static_cast<uint32_t>(index), static_cast<uint32_t>(length_));
- return *(reinterpret_cast<Object**>(reinterpret_cast<intptr_t>(arguments_) -
- index * kPointerSize));
- }
-
- template <class S> Handle<S> at(int index) {
- Object** value = &((*this)[index]);
- // This cast checks that the object we're accessing does indeed have the
- // expected type.
- S::cast(*value);
- return Handle<S>(reinterpret_cast<S**>(value));
- }
-
- int smi_at(int index) {
- return Smi::cast((*this)[index])->value();
- }
-
- double number_at(int index) {
- return (*this)[index]->Number();
- }
-
- // Get the total number of arguments including the receiver.
- int length() const { return static_cast<int>(length_); }
-
- Object** arguments() { return arguments_; }
-
- Object** lowest_address() { return &this->operator[](length() - 1); }
-
- Object** highest_address() { return &this->operator[](0); }
-
- private:
- intptr_t length_;
- Object** arguments_;
-};
-
-
// For each type of callback, we have a list of arguments
// They are used to generate the Call() functions below
// These aren't included in the list as they have duplicate signatures
@@ -95,21 +34,18 @@ class Arguments BASE_EMBEDDED {
F(IndexedPropertySetterCallback, v8::Value, uint32_t, v8::Local<v8::Value>)
#define FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(F) \
- F(AccessorNameSetterCallback, \
- void, \
- v8::Local<v8::Name>, \
- v8::Local<v8::Value>) \
-
+ F(AccessorNameSetterCallback, void, v8::Local<v8::Name>, v8::Local<v8::Value>)
// Custom arguments replicate a small segment of stack that can be
// accessed through an Arguments object the same way the actual stack
// can.
-template<int kArrayLength>
+template <int kArrayLength>
class CustomArgumentsBase : public Relocatable {
public:
virtual inline void IterateInstance(ObjectVisitor* v) {
v->VisitPointers(values_, values_ + kArrayLength);
}
+
protected:
inline Object** begin() { return values_; }
explicit inline CustomArgumentsBase(Isolate* isolate)
@@ -117,8 +53,7 @@ class CustomArgumentsBase : public Relocatable {
Object* values_[kArrayLength];
};
-
-template<typename T>
+template <typename T>
class CustomArguments : public CustomArgumentsBase<T::kArgsLength> {
public:
static const int kReturnValueOffset = T::kReturnValueIndex;
@@ -140,7 +75,6 @@ class CustomArguments : public CustomArgumentsBase<T::kArgsLength> {
}
};
-
class PropertyCallbackArguments
: public CustomArguments<PropertyCallbackInfo<Value> > {
public:
@@ -175,14 +109,14 @@ class PropertyCallbackArguments
DCHECK(values[T::kIsolateIndex]->IsSmi());
}
- /*
- * The following Call functions wrap the calling of all callbacks to handle
- * calling either the old or the new style callbacks depending on which one
- * has been registered.
- * For old callbacks which return an empty handle, the ReturnValue is checked
- * and used if it's been set to anything inside the callback.
- * New style callbacks always use the return value.
- */
+/*
+ * The following Call functions wrap the calling of all callbacks to handle
+ * calling either the old or the new style callbacks depending on which one
+ * has been registered.
+ * For old callbacks which return an empty handle, the ReturnValue is checked
+ * and used if it's been set to anything inside the callback.
+ * New style callbacks always use the return value.
+ */
#define WRITE_CALL_0(Function, ReturnValue) \
v8::Local<ReturnValue> Call(Function f);
@@ -192,13 +126,13 @@ class PropertyCallbackArguments
#define WRITE_CALL_2(Function, ReturnValue, Arg1, Arg2) \
v8::Local<ReturnValue> Call(Function f, Arg1 arg1, Arg2 arg2);
-#define WRITE_CALL_2_VOID(Function, ReturnValue, Arg1, Arg2) \
- void Call(Function f, Arg1 arg1, Arg2 arg2); \
+#define WRITE_CALL_2_VOID(Function, ReturnValue, Arg1, Arg2) \
+ void Call(Function f, Arg1 arg1, Arg2 arg2);
-FOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0)
-FOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1)
-FOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2)
-FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
+ FOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0)
+ FOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1)
+ FOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2)
+ FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
#undef WRITE_CALL_0
#undef WRITE_CALL_1
@@ -206,7 +140,6 @@ FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
#undef WRITE_CALL_2_VOID
};
-
class FunctionCallbackArguments
: public CustomArguments<FunctionCallbackInfo<Value> > {
public:
@@ -262,41 +195,7 @@ class FunctionCallbackArguments
bool is_construct_call_;
};
-
-double ClobberDoubleRegisters(double x1, double x2, double x3, double x4);
-
-
-#ifdef DEBUG
-#define CLOBBER_DOUBLE_REGISTERS() ClobberDoubleRegisters(1, 2, 3, 4);
-#else
-#define CLOBBER_DOUBLE_REGISTERS()
-#endif
-
-#define RUNTIME_FUNCTION_RETURNS_TYPE(Type, Name) \
- static INLINE(Type __RT_impl_##Name(Arguments args, Isolate* isolate)); \
- Type Name(int args_length, Object** args_object, Isolate* isolate) { \
- CLOBBER_DOUBLE_REGISTERS(); \
- Arguments args(args_length, args_object); \
- Type value; \
- TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), "V8." #Name); \
- if (FLAG_runtime_call_stats) { \
- RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \
- RuntimeCallTimerScope timer(isolate, &stats->Name); \
- value = __RT_impl_##Name(args, isolate); \
- } else { \
- value = __RT_impl_##Name(args, isolate); \
- } \
- return value; \
- } \
- static Type __RT_impl_##Name(Arguments args, Isolate* isolate)
-
-#define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name)
-#define RUNTIME_FUNCTION_RETURN_PAIR(Name) \
- RUNTIME_FUNCTION_RETURNS_TYPE(ObjectPair, Name)
-#define RUNTIME_FUNCTION_RETURN_TRIPLE(Name) \
- RUNTIME_FUNCTION_RETURNS_TYPE(ObjectTriple, Name)
-
} // namespace internal
} // namespace v8
-#endif // V8_ARGUMENTS_H_
+#endif // V8_API_ARGUMENTS_H_
« no previous file with comments | « BUILD.gn ('k') | src/api-arguments.cc » ('j') | src/arm/code-stubs-arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698