Move i18n-related runtime functions into a separate file.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/597943003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24202 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2014-09-25 07:16:15 +00:00
parent 134bba4967
commit 2a67e48f0e
39 changed files with 2193 additions and 2519 deletions

View File

@ -820,8 +820,10 @@ source_set("v8_base") {
"src/rewriter.h",
"src/runtime-profiler.cc",
"src/runtime-profiler.h",
"src/runtime.cc",
"src/runtime.h",
"src/runtime/runtime-i18n.cc",
"src/runtime/runtime-utils.h",
"src/runtime/runtime.cc",
"src/runtime/runtime.h",
"src/safepoint-table.cc",
"src/safepoint-table.h",
"src/sampler.cc",

View File

@ -38,7 +38,7 @@
#include "src/property.h"
#include "src/property-details.h"
#include "src/prototype.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/runtime-profiler.h"
#include "src/scanner-character-streams.h"
#include "src/simulator.h"

View File

@ -10,7 +10,7 @@
#include "src/debug.h"
#include "src/deoptimizer.h"
#include "src/full-codegen.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -15,7 +15,7 @@
#include "src/isolate.h"
#include "src/jsregexp.h"
#include "src/regexp-macro-assembler.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -15,7 +15,7 @@
#include "src/cpu-profiler.h"
#include "src/debug.h"
#include "src/isolate-inl.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -10,7 +10,7 @@
#include "src/debug.h"
#include "src/deoptimizer.h"
#include "src/full-codegen.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -14,7 +14,7 @@
#include "src/isolate.h"
#include "src/jsregexp.h"
#include "src/regexp-macro-assembler.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -13,7 +13,7 @@
#include "src/cpu-profiler.h"
#include "src/debug.h"
#include "src/isolate-inl.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -52,7 +52,7 @@
#include "src/jsregexp.h"
#include "src/regexp-macro-assembler.h"
#include "src/regexp-stack.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/serialize.h"
#include "src/token.h"

View File

@ -41,7 +41,7 @@
#include "src/builtins.h"
#include "src/gdb-jit.h"
#include "src/isolate.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/token.h"
namespace v8 {

View File

@ -16,7 +16,7 @@
#include "src/isolate.h"
#include "src/jsregexp.h"
#include "src/list-inl.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/small-pointer-list.h"
#include "src/smart-pointers.h"
#include "src/token.h"

View File

@ -11,7 +11,7 @@
#include "src/debug.h"
#include "src/prettyprinter.h"
#include "src/rewriter.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -6,7 +6,7 @@
#define V8_CODEGEN_H_
#include "src/code-stubs.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
// Include the declaration of the architecture defined class CodeGenerator.
// The contract to the shared code is that the the CodeGenerator is a subclass

View File

@ -40,7 +40,7 @@
#include "src/ic/ic-inl.h"
#include "src/lithium-allocator.h"
#include "src/parser.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/scopeinfo.h"
#include "src/scopes.h"
#include "src/typing.h"

View File

@ -15,7 +15,7 @@
#include "src/isolate.h"
#include "src/jsregexp.h"
#include "src/regexp-macro-assembler.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -13,7 +13,7 @@
#include "src/cpu-profiler.h"
#include "src/debug.h"
#include "src/isolate-inl.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/serialize.h"
namespace v8 {

View File

@ -17,7 +17,7 @@
#include "src/ic/ic-compiler.h"
#include "src/ic/stub-cache.h"
#include "src/prototype.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -20,7 +20,7 @@
#include "src/heap/heap.h"
#include "src/optimizing-compiler-thread.h"
#include "src/regexp-stack.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/runtime-profiler.h"
#include "src/zone.h"

View File

@ -18,7 +18,7 @@
#include "src/regexp-macro-assembler-irregexp.h"
#include "src/regexp-macro-assembler-tracer.h"
#include "src/regexp-stack.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/string-search.h"
#ifndef V8_INTERPRETED_REGEXP

View File

@ -12,7 +12,7 @@
#include "src/debug.h"
#include "src/deoptimizer.h"
#include "src/full-codegen.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {

View File

@ -15,7 +15,7 @@
#include "src/isolate.h"
#include "src/jsregexp.h"
#include "src/regexp-macro-assembler.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -15,7 +15,7 @@
#include "src/cpu-profiler.h"
#include "src/debug.h"
#include "src/isolate-inl.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -12,7 +12,7 @@
#include "src/debug.h"
#include "src/deoptimizer.h"
#include "src/full-codegen.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -14,7 +14,7 @@
#include "src/isolate.h"
#include "src/jsregexp.h"
#include "src/regexp-macro-assembler.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -14,7 +14,7 @@
#include "src/cpu-profiler.h"
#include "src/debug.h"
#include "src/isolate-inl.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -15,7 +15,7 @@
#include "src/messages.h"
#include "src/parser.h"
#include "src/preparser.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/scanner-character-streams.h"
#include "src/scopeinfo.h"
#include "src/string-stream.h"

751
src/runtime/runtime-i18n.cc Normal file
View File

@ -0,0 +1,751 @@
// 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.
#ifdef V8_I18N_SUPPORT
#include "src/v8.h"
#include "src/arguments.h"
#include "src/i18n.h"
#include "src/runtime/runtime.h"
#include "src/runtime/runtime-utils.h"
#include "unicode/brkiter.h"
#include "unicode/calendar.h"
#include "unicode/coll.h"
#include "unicode/curramt.h"
#include "unicode/datefmt.h"
#include "unicode/dcfmtsym.h"
#include "unicode/decimfmt.h"
#include "unicode/dtfmtsym.h"
#include "unicode/dtptngen.h"
#include "unicode/locid.h"
#include "unicode/numfmt.h"
#include "unicode/numsys.h"
#include "unicode/rbbi.h"
#include "unicode/smpdtfmt.h"
#include "unicode/timezone.h"
#include "unicode/uchar.h"
#include "unicode/ucol.h"
#include "unicode/ucurr.h"
#include "unicode/uloc.h"
#include "unicode/unum.h"
#include "unicode/uversion.h"
namespace v8 {
namespace internal {
RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) {
HandleScope scope(isolate);
Factory* factory = isolate->factory();
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0);
v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str));
// Return value which denotes invalid language tag.
const char* const kInvalidTag = "invalid-tag";
UErrorCode error = U_ZERO_ERROR;
char icu_result[ULOC_FULLNAME_CAPACITY];
int icu_length = 0;
uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY,
&icu_length, &error);
if (U_FAILURE(error) || icu_length == 0) {
return *factory->NewStringFromAsciiChecked(kInvalidTag);
}
char result[ULOC_FULLNAME_CAPACITY];
// Force strict BCP47 rules.
uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error);
if (U_FAILURE(error)) {
return *factory->NewStringFromAsciiChecked(kInvalidTag);
}
return *factory->NewStringFromAsciiChecked(result);
}
RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) {
HandleScope scope(isolate);
Factory* factory = isolate->factory();
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, service, 0);
const icu::Locale* available_locales = NULL;
int32_t count = 0;
if (service->IsUtf8EqualTo(CStrVector("collator"))) {
available_locales = icu::Collator::getAvailableLocales(count);
} else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) {
available_locales = icu::NumberFormat::getAvailableLocales(count);
} else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) {
available_locales = icu::DateFormat::getAvailableLocales(count);
} else if (service->IsUtf8EqualTo(CStrVector("breakiterator"))) {
available_locales = icu::BreakIterator::getAvailableLocales(count);
}
UErrorCode error = U_ZERO_ERROR;
char result[ULOC_FULLNAME_CAPACITY];
Handle<JSObject> locales = factory->NewJSObject(isolate->object_function());
for (int32_t i = 0; i < count; ++i) {
const char* icu_name = available_locales[i].getName();
error = U_ZERO_ERROR;
// No need to force strict BCP47 rules.
uloc_toLanguageTag(icu_name, result, ULOC_FULLNAME_CAPACITY, FALSE, &error);
if (U_FAILURE(error)) {
// This shouldn't happen, but lets not break the user.
continue;
}
RETURN_FAILURE_ON_EXCEPTION(
isolate, JSObject::SetOwnPropertyIgnoreAttributes(
locales, factory->NewStringFromAsciiChecked(result),
factory->NewNumber(i), NONE));
}
return *locales;
}
RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) {
HandleScope scope(isolate);
Factory* factory = isolate->factory();
DCHECK(args.length() == 0);
icu::Locale default_locale;
// Set the locale
char result[ULOC_FULLNAME_CAPACITY];
UErrorCode status = U_ZERO_ERROR;
uloc_toLanguageTag(default_locale.getName(), result, ULOC_FULLNAME_CAPACITY,
FALSE, &status);
if (U_SUCCESS(status)) {
return *factory->NewStringFromAsciiChecked(result);
}
return *factory->NewStringFromStaticChars("und");
}
RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) {
HandleScope scope(isolate);
Factory* factory = isolate->factory();
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0);
uint32_t length = static_cast<uint32_t>(input->length()->Number());
// Set some limit to prevent fuzz tests from going OOM.
// Can be bumped when callers' requirements change.
RUNTIME_ASSERT(length < 100);
Handle<FixedArray> output = factory->NewFixedArray(length);
Handle<Name> maximized = factory->NewStringFromStaticChars("maximized");
Handle<Name> base = factory->NewStringFromStaticChars("base");
for (unsigned int i = 0; i < length; ++i) {
Handle<Object> locale_id;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, locale_id,
Object::GetElement(isolate, input, i));
if (!locale_id->IsString()) {
return isolate->Throw(*factory->illegal_argument_string());
}
v8::String::Utf8Value utf8_locale_id(
v8::Utils::ToLocal(Handle<String>::cast(locale_id)));
UErrorCode error = U_ZERO_ERROR;
// Convert from BCP47 to ICU format.
// de-DE-u-co-phonebk -> de_DE@collation=phonebook
char icu_locale[ULOC_FULLNAME_CAPACITY];
int icu_locale_length = 0;
uloc_forLanguageTag(*utf8_locale_id, icu_locale, ULOC_FULLNAME_CAPACITY,
&icu_locale_length, &error);
if (U_FAILURE(error) || icu_locale_length == 0) {
return isolate->Throw(*factory->illegal_argument_string());
}
// Maximize the locale.
// de_DE@collation=phonebook -> de_Latn_DE@collation=phonebook
char icu_max_locale[ULOC_FULLNAME_CAPACITY];
uloc_addLikelySubtags(icu_locale, icu_max_locale, ULOC_FULLNAME_CAPACITY,
&error);
// Remove extensions from maximized locale.
// de_Latn_DE@collation=phonebook -> de_Latn_DE
char icu_base_max_locale[ULOC_FULLNAME_CAPACITY];
uloc_getBaseName(icu_max_locale, icu_base_max_locale,
ULOC_FULLNAME_CAPACITY, &error);
// Get original name without extensions.
// de_DE@collation=phonebook -> de_DE
char icu_base_locale[ULOC_FULLNAME_CAPACITY];
uloc_getBaseName(icu_locale, icu_base_locale, ULOC_FULLNAME_CAPACITY,
&error);
// Convert from ICU locale format to BCP47 format.
// de_Latn_DE -> de-Latn-DE
char base_max_locale[ULOC_FULLNAME_CAPACITY];
uloc_toLanguageTag(icu_base_max_locale, base_max_locale,
ULOC_FULLNAME_CAPACITY, FALSE, &error);
// de_DE -> de-DE
char base_locale[ULOC_FULLNAME_CAPACITY];
uloc_toLanguageTag(icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY,
FALSE, &error);
if (U_FAILURE(error)) {
return isolate->Throw(*factory->illegal_argument_string());
}
Handle<JSObject> result = factory->NewJSObject(isolate->object_function());
Handle<String> value = factory->NewStringFromAsciiChecked(base_max_locale);
JSObject::AddProperty(result, maximized, value, NONE);
value = factory->NewStringFromAsciiChecked(base_locale);
JSObject::AddProperty(result, base, value, NONE);
output->set(i, *result);
}
Handle<JSArray> result = factory->NewJSArrayWithElements(output);
result->set_length(Smi::FromInt(length));
return *result;
}
RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
if (!input->IsJSObject()) return isolate->heap()->false_value();
Handle<JSObject> obj = Handle<JSObject>::cast(input);
Handle<String> marker = isolate->factory()->intl_initialized_marker_string();
Handle<Object> tag(obj->GetHiddenProperty(marker), isolate);
return isolate->heap()->ToBoolean(!tag->IsTheHole());
}
RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1);
if (!input->IsJSObject()) return isolate->heap()->false_value();
Handle<JSObject> obj = Handle<JSObject>::cast(input);
Handle<String> marker = isolate->factory()->intl_initialized_marker_string();
Handle<Object> tag(obj->GetHiddenProperty(marker), isolate);
return isolate->heap()->ToBoolean(tag->IsString() &&
String::cast(*tag)->Equals(*expected_type));
}
RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0);
CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2);
Handle<String> marker = isolate->factory()->intl_initialized_marker_string();
JSObject::SetHiddenProperty(input, marker, type);
marker = isolate->factory()->intl_impl_object_string();
JSObject::SetHiddenProperty(input, marker, impl);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
if (!input->IsJSObject()) {
Vector<Handle<Object> > arguments = HandleVector(&input, 1);
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
NewTypeError("not_intl_object", arguments));
}
Handle<JSObject> obj = Handle<JSObject>::cast(input);
Handle<String> marker = isolate->factory()->intl_impl_object_string();
Handle<Object> impl(obj->GetHiddenProperty(marker), isolate);
if (impl->IsTheHole()) {
Vector<Handle<Object> > arguments = HandleVector(&obj, 1);
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
NewTypeError("not_intl_object", arguments));
}
return *impl;
}
RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
Handle<ObjectTemplateInfo> date_format_template = I18N::GetTemplate(isolate);
// Create an empty object wrapper.
Handle<JSObject> local_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, local_object,
Execution::InstantiateObject(date_format_template));
// Set date time formatter as internal field of the resulting JS object.
icu::SimpleDateFormat* date_format =
DateFormat::InitializeDateTimeFormat(isolate, locale, options, resolved);
if (!date_format) return isolate->ThrowIllegalOperation();
local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format));
Factory* factory = isolate->factory();
Handle<String> key = factory->NewStringFromStaticChars("dateFormat");
Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
// Make object handle weak so we can delete the data format once GC kicks in.
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(wrapper.location(),
reinterpret_cast<void*>(wrapper.location()),
DateFormat::DeleteDateFormat);
return *local_object;
}
RUNTIME_FUNCTION(Runtime_InternalDateFormat) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1);
Handle<Object> value;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
Execution::ToNumber(isolate, date));
icu::SimpleDateFormat* date_format =
DateFormat::UnpackDateFormat(isolate, date_format_holder);
if (!date_format) return isolate->ThrowIllegalOperation();
icu::UnicodeString result;
date_format->format(value->Number(), result);
Handle<String> result_str;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result_str,
isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
reinterpret_cast<const uint16_t*>(result.getBuffer()),
result.length())));
return *result_str;
}
RUNTIME_FUNCTION(Runtime_InternalDateParse) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1);
v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string));
icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date));
icu::SimpleDateFormat* date_format =
DateFormat::UnpackDateFormat(isolate, date_format_holder);
if (!date_format) return isolate->ThrowIllegalOperation();
UErrorCode status = U_ZERO_ERROR;
UDate date = date_format->parse(u_date, status);
if (U_FAILURE(status)) return isolate->heap()->undefined_value();
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, Execution::NewDate(isolate, static_cast<double>(date)));
DCHECK(result->IsJSDate());
return *result;
}
RUNTIME_FUNCTION(Runtime_CreateNumberFormat) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
Handle<ObjectTemplateInfo> number_format_template =
I18N::GetTemplate(isolate);
// Create an empty object wrapper.
Handle<JSObject> local_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, local_object,
Execution::InstantiateObject(number_format_template));
// Set number formatter as internal field of the resulting JS object.
icu::DecimalFormat* number_format =
NumberFormat::InitializeNumberFormat(isolate, locale, options, resolved);
if (!number_format) return isolate->ThrowIllegalOperation();
local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format));
Factory* factory = isolate->factory();
Handle<String> key = factory->NewStringFromStaticChars("numberFormat");
Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(wrapper.location(),
reinterpret_cast<void*>(wrapper.location()),
NumberFormat::DeleteNumberFormat);
return *local_object;
}
RUNTIME_FUNCTION(Runtime_InternalNumberFormat) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, number, 1);
Handle<Object> value;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
Execution::ToNumber(isolate, number));
icu::DecimalFormat* number_format =
NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
if (!number_format) return isolate->ThrowIllegalOperation();
icu::UnicodeString result;
number_format->format(value->Number(), result);
Handle<String> result_str;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result_str,
isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
reinterpret_cast<const uint16_t*>(result.getBuffer()),
result.length())));
return *result_str;
}
RUNTIME_FUNCTION(Runtime_InternalNumberParse) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1);
v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string));
icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number));
icu::DecimalFormat* number_format =
NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
if (!number_format) return isolate->ThrowIllegalOperation();
UErrorCode status = U_ZERO_ERROR;
icu::Formattable result;
// ICU 4.6 doesn't support parseCurrency call. We need to wait for ICU49
// to be part of Chrome.
// TODO(cira): Include currency parsing code using parseCurrency call.
// We need to check if the formatter parses all currencies or only the
// one it was constructed with (it will impact the API - how to return ISO
// code and the value).
number_format->parse(u_number, result, status);
if (U_FAILURE(status)) return isolate->heap()->undefined_value();
switch (result.getType()) {
case icu::Formattable::kDouble:
return *isolate->factory()->NewNumber(result.getDouble());
case icu::Formattable::kLong:
return *isolate->factory()->NewNumberFromInt(result.getLong());
case icu::Formattable::kInt64:
return *isolate->factory()->NewNumber(
static_cast<double>(result.getInt64()));
default:
return isolate->heap()->undefined_value();
}
}
RUNTIME_FUNCTION(Runtime_CreateCollator) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate);
// Create an empty object wrapper.
Handle<JSObject> local_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, local_object, Execution::InstantiateObject(collator_template));
// Set collator as internal field of the resulting JS object.
icu::Collator* collator =
Collator::InitializeCollator(isolate, locale, options, resolved);
if (!collator) return isolate->ThrowIllegalOperation();
local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator));
Factory* factory = isolate->factory();
Handle<String> key = factory->NewStringFromStaticChars("collator");
Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(wrapper.location(),
reinterpret_cast<void*>(wrapper.location()),
Collator::DeleteCollator);
return *local_object;
}
RUNTIME_FUNCTION(Runtime_InternalCompare) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(String, string1, 1);
CONVERT_ARG_HANDLE_CHECKED(String, string2, 2);
icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder);
if (!collator) return isolate->ThrowIllegalOperation();
v8::String::Value string_value1(v8::Utils::ToLocal(string1));
v8::String::Value string_value2(v8::Utils::ToLocal(string2));
const UChar* u_string1 = reinterpret_cast<const UChar*>(*string_value1);
const UChar* u_string2 = reinterpret_cast<const UChar*>(*string_value2);
UErrorCode status = U_ZERO_ERROR;
UCollationResult result =
collator->compare(u_string1, string_value1.length(), u_string2,
string_value2.length(), status);
if (U_FAILURE(status)) return isolate->ThrowIllegalOperation();
return *isolate->factory()->NewNumberFromInt(result);
}
RUNTIME_FUNCTION(Runtime_StringNormalize) {
HandleScope scope(isolate);
static const UNormalizationMode normalizationForms[] = {
UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD};
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0);
CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]);
RUNTIME_ASSERT(form_id >= 0 &&
static_cast<size_t>(form_id) < arraysize(normalizationForms));
v8::String::Value string_value(v8::Utils::ToLocal(stringValue));
const UChar* u_value = reinterpret_cast<const UChar*>(*string_value);
// TODO(mnita): check Normalizer2 (not available in ICU 46)
UErrorCode status = U_ZERO_ERROR;
icu::UnicodeString result;
icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0, result,
status);
if (U_FAILURE(status)) {
return isolate->heap()->undefined_value();
}
Handle<String> result_str;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result_str,
isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
reinterpret_cast<const uint16_t*>(result.getBuffer()),
result.length())));
return *result_str;
}
RUNTIME_FUNCTION(Runtime_CreateBreakIterator) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
Handle<ObjectTemplateInfo> break_iterator_template =
I18N::GetTemplate2(isolate);
// Create an empty object wrapper.
Handle<JSObject> local_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, local_object,
Execution::InstantiateObject(break_iterator_template));
// Set break iterator as internal field of the resulting JS object.
icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator(
isolate, locale, options, resolved);
if (!break_iterator) return isolate->ThrowIllegalOperation();
local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator));
// Make sure that the pointer to adopted text is NULL.
local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL));
Factory* factory = isolate->factory();
Handle<String> key = factory->NewStringFromStaticChars("breakIterator");
Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
// Make object handle weak so we can delete the break iterator once GC kicks
// in.
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(wrapper.location(),
reinterpret_cast<void*>(wrapper.location()),
BreakIterator::DeleteBreakIterator);
return *local_object;
}
RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(String, text, 1);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
if (!break_iterator) return isolate->ThrowIllegalOperation();
icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>(
break_iterator_holder->GetInternalField(1));
delete u_text;
v8::String::Value text_value(v8::Utils::ToLocal(text));
u_text = new icu::UnicodeString(reinterpret_cast<const UChar*>(*text_value),
text_value.length());
break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text));
break_iterator->setText(*u_text);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
if (!break_iterator) return isolate->ThrowIllegalOperation();
return *isolate->factory()->NewNumberFromInt(break_iterator->first());
}
RUNTIME_FUNCTION(Runtime_BreakIteratorNext) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
if (!break_iterator) return isolate->ThrowIllegalOperation();
return *isolate->factory()->NewNumberFromInt(break_iterator->next());
}
RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
if (!break_iterator) return isolate->ThrowIllegalOperation();
return *isolate->factory()->NewNumberFromInt(break_iterator->current());
}
RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
if (!break_iterator) return isolate->ThrowIllegalOperation();
// TODO(cira): Remove cast once ICU fixes base BreakIterator class.
icu::RuleBasedBreakIterator* rule_based_iterator =
static_cast<icu::RuleBasedBreakIterator*>(break_iterator);
int32_t status = rule_based_iterator->getRuleStatus();
// Keep return values in sync with JavaScript BreakType enum.
if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
return *isolate->factory()->NewStringFromStaticChars("none");
} else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) {
return *isolate->factory()->number_string();
} else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) {
return *isolate->factory()->NewStringFromStaticChars("letter");
} else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
return *isolate->factory()->NewStringFromStaticChars("kana");
} else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) {
return *isolate->factory()->NewStringFromStaticChars("ideo");
} else {
return *isolate->factory()->NewStringFromStaticChars("unknown");
}
}
}
} // namespace v8::internal
#endif // V8_I18N_SUPPORT

146
src/runtime/runtime-utils.h Normal file
View File

@ -0,0 +1,146 @@
// 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.
#ifndef V8_RUNTIME_UTILS_H_
#define V8_RUNTIME_UTILS_H_
namespace v8 {
namespace internal {
#define RUNTIME_ASSERT(value) \
if (!(value)) return isolate->ThrowIllegalOperation();
#define RUNTIME_ASSERT_HANDLIFIED(value, T) \
if (!(value)) { \
isolate->ThrowIllegalOperation(); \
return MaybeHandle<T>(); \
}
// Cast the given object to a value of the specified type and store
// it in a variable with the given name. If the object is not of the
// expected type call IllegalOperation and return.
#define CONVERT_ARG_CHECKED(Type, name, index) \
RUNTIME_ASSERT(args[index]->Is##Type()); \
Type* name = Type::cast(args[index]);
#define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \
RUNTIME_ASSERT(args[index]->Is##Type()); \
Handle<Type> name = args.at<Type>(index);
#define CONVERT_NUMBER_ARG_HANDLE_CHECKED(name, index) \
RUNTIME_ASSERT(args[index]->IsNumber()); \
Handle<Object> name = args.at<Object>(index);
// Cast the given object to a boolean and store it in a variable with
// the given name. If the object is not a boolean call IllegalOperation
// and return.
#define CONVERT_BOOLEAN_ARG_CHECKED(name, index) \
RUNTIME_ASSERT(args[index]->IsBoolean()); \
bool name = args[index]->IsTrue();
// Cast the given argument to a Smi and store its value in an int variable
// with the given name. If the argument is not a Smi call IllegalOperation
// and return.
#define CONVERT_SMI_ARG_CHECKED(name, index) \
RUNTIME_ASSERT(args[index]->IsSmi()); \
int name = args.smi_at(index);
// Cast the given argument to a double and store it in a variable with
// the given name. If the argument is not a number (as opposed to
// the number not-a-number) call IllegalOperation and return.
#define CONVERT_DOUBLE_ARG_CHECKED(name, index) \
RUNTIME_ASSERT(args[index]->IsNumber()); \
double name = args.number_at(index);
// Call the specified converter on the object *comand store the result in
// a variable of the specified type with the given name. If the
// object is not a Number call IllegalOperation and return.
#define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
RUNTIME_ASSERT(obj->IsNumber()); \
type name = NumberTo##Type(obj);
// Cast the given argument to PropertyDetails and store its value in a
// variable with the given name. If the argument is not a Smi call
// IllegalOperation and return.
#define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \
RUNTIME_ASSERT(args[index]->IsSmi()); \
PropertyDetails name = PropertyDetails(Smi::cast(args[index]));
// Assert that the given argument has a valid value for a StrictMode
// and store it in a StrictMode variable with the given name.
#define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \
RUNTIME_ASSERT(args[index]->IsSmi()); \
RUNTIME_ASSERT(args.smi_at(index) == STRICT || \
args.smi_at(index) == SLOPPY); \
StrictMode name = static_cast<StrictMode>(args.smi_at(index));
// Assert that the given argument is a number within the Int32 range
// and convert it to int32_t. If the argument is not an Int32 call
// IllegalOperation and return.
#define CONVERT_INT32_ARG_CHECKED(name, index) \
RUNTIME_ASSERT(args[index]->IsNumber()); \
int32_t name = 0; \
RUNTIME_ASSERT(args[index]->ToInt32(&name));
// A mechanism to return a pair of Object pointers in registers (if possible).
// How this is achieved is calling convention-dependent.
// All currently supported x86 compiles uses calling conventions that are cdecl
// variants where a 64-bit value is returned in two 32-bit registers
// (edx:eax on ia32, r1:r0 on ARM).
// In AMD-64 calling convention a struct of two pointers is returned in rdx:rax.
// In Win64 calling convention, a struct of two pointers is returned in memory,
// allocated by the caller, and passed as a pointer in a hidden first parameter.
#ifdef V8_HOST_ARCH_64_BIT
struct ObjectPair {
Object* x;
Object* y;
};
static inline ObjectPair MakePair(Object* x, Object* y) {
ObjectPair result = {x, y};
// Pointers x and y returned in rax and rdx, in AMD-x64-abi.
// In Win64 they are assigned to a hidden first argument.
return result;
}
#elif V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT
// For x32 a 128-bit struct return is done as rax and rdx from the ObjectPair
// are used in the full codegen and Crankshaft compiler. An alternative is
// using uint64_t and modifying full codegen and Crankshaft compiler.
struct ObjectPair {
Object* x;
uint32_t x_upper;
Object* y;
uint32_t y_upper;
};
static inline ObjectPair MakePair(Object* x, Object* y) {
ObjectPair result = {x, 0, y, 0};
// Pointers x and y returned in rax and rdx, in x32-abi.
return result;
}
#else
typedef uint64_t ObjectPair;
static inline ObjectPair MakePair(Object* x, Object* y) {
#if defined(V8_TARGET_LITTLE_ENDIAN)
return reinterpret_cast<uint32_t>(x) |
(reinterpret_cast<ObjectPair>(y) << 32);
#elif defined(V8_TARGET_BIG_ENDIAN)
return reinterpret_cast<uint32_t>(y) |
(reinterpret_cast<ObjectPair>(x) << 32);
#else
#error Unknown endianness
#endif
}
#endif
}
} // namespace v8::internal
#endif // V8_RUNTIME_UTILS_H_

File diff suppressed because it is too large Load Diff

View File

@ -189,241 +189,239 @@ namespace internal {
F(LoadFromSuper, 3, 1)
#define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
/* Reflection */ \
F(FunctionSetInstanceClassName, 2, 1) \
F(FunctionSetLength, 2, 1) \
F(FunctionSetPrototype, 2, 1) \
F(FunctionGetName, 1, 1) \
F(FunctionSetName, 2, 1) \
F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
F(FunctionIsGenerator, 1, 1) \
F(FunctionIsArrow, 1, 1) \
F(FunctionIsConciseMethod, 1, 1) \
F(FunctionBindArguments, 4, 1) \
F(BoundFunctionGetBindings, 1, 1) \
F(FunctionRemovePrototype, 1, 1) \
F(FunctionGetSourceCode, 1, 1) \
F(FunctionGetScript, 1, 1) \
F(FunctionGetScriptSourcePosition, 1, 1) \
F(FunctionGetPositionForOffset, 2, 1) \
F(FunctionIsAPIFunction, 1, 1) \
F(FunctionIsBuiltin, 1, 1) \
F(GetScript, 1, 1) \
F(CollectStackTrace, 2, 1) \
F(GetV8Version, 0, 1) \
F(GeneratorGetFunction, 1, 1) \
F(GeneratorGetContext, 1, 1) \
F(GeneratorGetReceiver, 1, 1) \
F(GeneratorGetContinuation, 1, 1) \
F(GeneratorGetSourcePosition, 1, 1) \
\
F(SetCode, 2, 1) \
\
F(CreateApiFunction, 2, 1) \
F(IsTemplate, 1, 1) \
F(GetTemplateField, 2, 1) \
F(DisableAccessChecks, 1, 1) \
F(EnableAccessChecks, 1, 1) \
\
/* Dates */ \
F(DateCurrentTime, 0, 1) \
F(DateParseString, 2, 1) \
F(DateLocalTimezone, 1, 1) \
F(DateToUTC, 1, 1) \
F(DateMakeDay, 2, 1) \
F(DateSetValue, 3, 1) \
F(DateCacheVersion, 0, 1) \
\
/* Globals */ \
F(CompileString, 2, 1) \
\
/* Eval */ \
F(GlobalProxy, 1, 1) \
F(IsAttachedGlobal, 1, 1) \
\
F(AddNamedProperty, 4, 1) \
F(AddPropertyForTemplate, 4, 1) \
F(SetProperty, 4, 1) \
F(AddElement, 4, 1) \
F(DefineApiAccessorProperty, 5, 1) \
F(DefineDataPropertyUnchecked, 4, 1) \
F(DefineAccessorPropertyUnchecked, 5, 1) \
F(GetDataProperty, 2, 1) \
F(SetHiddenProperty, 3, 1) \
\
/* Arrays */ \
F(RemoveArrayHoles, 2, 1) \
F(GetArrayKeys, 2, 1) \
F(MoveArrayContents, 2, 1) \
F(EstimateNumberOfElements, 1, 1) \
F(NormalizeElements, 1, 1) \
\
/* Getters and Setters */ \
F(LookupAccessor, 3, 1) \
\
/* ES5 */ \
F(ObjectFreeze, 1, 1) \
\
/* Harmony modules */ \
F(IsJSModule, 1, 1) \
\
/* Harmony symbols */ \
F(CreateSymbol, 1, 1) \
F(CreatePrivateSymbol, 1, 1) \
F(CreateGlobalPrivateOwnSymbol, 1, 1) \
F(CreatePrivateOwnSymbol, 1, 1) \
F(NewSymbolWrapper, 1, 1) \
F(SymbolDescription, 1, 1) \
F(SymbolRegistry, 0, 1) \
F(SymbolIsPrivate, 1, 1) \
\
/* Harmony proxies */ \
F(CreateJSProxy, 2, 1) \
F(CreateJSFunctionProxy, 4, 1) \
F(IsJSProxy, 1, 1) \
F(IsJSFunctionProxy, 1, 1) \
F(GetHandler, 1, 1) \
F(GetCallTrap, 1, 1) \
F(GetConstructTrap, 1, 1) \
F(Fix, 1, 1) \
\
/* Harmony sets */ \
F(SetInitialize, 1, 1) \
F(SetAdd, 2, 1) \
F(SetHas, 2, 1) \
F(SetDelete, 2, 1) \
F(SetClear, 1, 1) \
F(SetGetSize, 1, 1) \
\
F(SetIteratorInitialize, 3, 1) \
F(SetIteratorNext, 2, 1) \
\
/* Harmony maps */ \
F(MapInitialize, 1, 1) \
F(MapGet, 2, 1) \
F(MapHas, 2, 1) \
F(MapDelete, 2, 1) \
F(MapClear, 1, 1) \
F(MapSet, 3, 1) \
F(MapGetSize, 1, 1) \
\
F(MapIteratorInitialize, 3, 1) \
F(MapIteratorNext, 2, 1) \
\
/* Harmony weak maps and sets */ \
F(WeakCollectionInitialize, 1, 1) \
F(WeakCollectionGet, 2, 1) \
F(WeakCollectionHas, 2, 1) \
F(WeakCollectionDelete, 2, 1) \
F(WeakCollectionSet, 3, 1) \
\
F(GetWeakMapEntries, 1, 1) \
F(GetWeakSetValues, 1, 1) \
\
/* Harmony events */ \
F(EnqueueMicrotask, 1, 1) \
F(RunMicrotasks, 0, 1) \
\
/* Harmony observe */ \
F(IsObserved, 1, 1) \
F(SetIsObserved, 1, 1) \
F(GetObservationState, 0, 1) \
F(ObservationWeakMapCreate, 0, 1) \
F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
F(GetObjectContextObjectObserve, 1, 1) \
F(GetObjectContextObjectGetNotifier, 1, 1) \
F(GetObjectContextNotifierPerformChange, 1, 1) \
\
/* Harmony typed arrays */ \
F(ArrayBufferInitialize, 2, 1) \
F(ArrayBufferSliceImpl, 3, 1) \
F(ArrayBufferIsView, 1, 1) \
F(ArrayBufferNeuter, 1, 1) \
\
F(TypedArrayInitializeFromArrayLike, 4, 1) \
F(TypedArrayGetBuffer, 1, 1) \
F(TypedArraySetFastCases, 3, 1) \
\
F(DataViewGetBuffer, 1, 1) \
F(DataViewGetInt8, 3, 1) \
F(DataViewGetUint8, 3, 1) \
F(DataViewGetInt16, 3, 1) \
F(DataViewGetUint16, 3, 1) \
F(DataViewGetInt32, 3, 1) \
F(DataViewGetUint32, 3, 1) \
F(DataViewGetFloat32, 3, 1) \
F(DataViewGetFloat64, 3, 1) \
\
F(DataViewSetInt8, 4, 1) \
F(DataViewSetUint8, 4, 1) \
F(DataViewSetInt16, 4, 1) \
F(DataViewSetUint16, 4, 1) \
F(DataViewSetInt32, 4, 1) \
F(DataViewSetUint32, 4, 1) \
F(DataViewSetFloat32, 4, 1) \
F(DataViewSetFloat64, 4, 1) \
\
/* Statements */ \
F(NewObjectFromBound, 1, 1) \
\
/* Declarations and initialization */ \
F(InitializeVarGlobal, 3, 1) \
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
\
/* Debugging */ \
F(DebugPrint, 1, 1) \
F(GlobalPrint, 1, 1) \
F(DebugTrace, 0, 1) \
F(TraceEnter, 0, 1) \
F(TraceExit, 1, 1) \
F(Abort, 1, 1) \
F(AbortJS, 1, 1) \
/* ES5 */ \
F(OwnKeys, 1, 1) \
\
/* Message objects */ \
F(MessageGetStartPosition, 1, 1) \
F(MessageGetScript, 1, 1) \
\
/* Pseudo functions - handled as macros by parser */ \
F(IS_VAR, 1, 1) \
\
/* expose boolean functions from objects-inl.h */ \
F(HasFastSmiElements, 1, 1) \
F(HasFastSmiOrObjectElements, 1, 1) \
F(HasFastObjectElements, 1, 1) \
F(HasFastDoubleElements, 1, 1) \
F(HasFastHoleyElements, 1, 1) \
F(HasDictionaryElements, 1, 1) \
F(HasSloppyArgumentsElements, 1, 1) \
F(HasExternalUint8ClampedElements, 1, 1) \
F(HasExternalArrayElements, 1, 1) \
F(HasExternalInt8Elements, 1, 1) \
F(HasExternalUint8Elements, 1, 1) \
F(HasExternalInt16Elements, 1, 1) \
F(HasExternalUint16Elements, 1, 1) \
F(HasExternalInt32Elements, 1, 1) \
F(HasExternalUint32Elements, 1, 1) \
F(HasExternalFloat32Elements, 1, 1) \
F(HasExternalFloat64Elements, 1, 1) \
F(HasFixedUint8ClampedElements, 1, 1) \
F(HasFixedInt8Elements, 1, 1) \
F(HasFixedUint8Elements, 1, 1) \
F(HasFixedInt16Elements, 1, 1) \
F(HasFixedUint16Elements, 1, 1) \
F(HasFixedInt32Elements, 1, 1) \
F(HasFixedUint32Elements, 1, 1) \
F(HasFixedFloat32Elements, 1, 1) \
F(HasFixedFloat64Elements, 1, 1) \
F(HasFastProperties, 1, 1) \
F(TransitionElementsKind, 2, 1) \
F(HaveSameMap, 2, 1) \
F(IsJSGlobalProxy, 1, 1) \
F(ForInInit, 2, 2) /* TODO(turbofan): Only temporary */ \
F(ForInNext, 4, 2) /* TODO(turbofan): Only temporary */ \
#define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
/* Reflection */ \
F(FunctionSetInstanceClassName, 2, 1) \
F(FunctionSetLength, 2, 1) \
F(FunctionSetPrototype, 2, 1) \
F(FunctionGetName, 1, 1) \
F(FunctionSetName, 2, 1) \
F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
F(FunctionIsGenerator, 1, 1) \
F(FunctionIsArrow, 1, 1) \
F(FunctionIsConciseMethod, 1, 1) \
F(FunctionBindArguments, 4, 1) \
F(BoundFunctionGetBindings, 1, 1) \
F(FunctionRemovePrototype, 1, 1) \
F(FunctionGetSourceCode, 1, 1) \
F(FunctionGetScript, 1, 1) \
F(FunctionGetScriptSourcePosition, 1, 1) \
F(FunctionGetPositionForOffset, 2, 1) \
F(FunctionIsAPIFunction, 1, 1) \
F(FunctionIsBuiltin, 1, 1) \
F(GetScript, 1, 1) \
F(CollectStackTrace, 2, 1) \
F(GetV8Version, 0, 1) \
F(GeneratorGetFunction, 1, 1) \
F(GeneratorGetContext, 1, 1) \
F(GeneratorGetReceiver, 1, 1) \
F(GeneratorGetContinuation, 1, 1) \
F(GeneratorGetSourcePosition, 1, 1) \
\
F(SetCode, 2, 1) \
\
F(CreateApiFunction, 2, 1) \
F(IsTemplate, 1, 1) \
F(GetTemplateField, 2, 1) \
F(DisableAccessChecks, 1, 1) \
F(EnableAccessChecks, 1, 1) \
\
/* Dates */ \
F(DateCurrentTime, 0, 1) \
F(DateParseString, 2, 1) \
F(DateLocalTimezone, 1, 1) \
F(DateToUTC, 1, 1) \
F(DateMakeDay, 2, 1) \
F(DateSetValue, 3, 1) \
F(DateCacheVersion, 0, 1) \
\
/* Globals */ \
F(CompileString, 2, 1) \
\
/* Eval */ \
F(GlobalProxy, 1, 1) \
F(IsAttachedGlobal, 1, 1) \
\
F(AddNamedProperty, 4, 1) \
F(AddPropertyForTemplate, 4, 1) \
F(SetProperty, 4, 1) \
F(AddElement, 4, 1) \
F(DefineApiAccessorProperty, 5, 1) \
F(DefineDataPropertyUnchecked, 4, 1) \
F(DefineAccessorPropertyUnchecked, 5, 1) \
F(GetDataProperty, 2, 1) \
F(SetHiddenProperty, 3, 1) \
\
/* Arrays */ \
F(RemoveArrayHoles, 2, 1) \
F(GetArrayKeys, 2, 1) \
F(MoveArrayContents, 2, 1) \
F(EstimateNumberOfElements, 1, 1) \
F(NormalizeElements, 1, 1) \
\
/* Getters and Setters */ \
F(LookupAccessor, 3, 1) \
\
/* ES5 */ \
F(ObjectFreeze, 1, 1) \
\
/* Harmony modules */ \
F(IsJSModule, 1, 1) \
\
/* Harmony symbols */ \
F(CreateSymbol, 1, 1) \
F(CreatePrivateSymbol, 1, 1) \
F(CreateGlobalPrivateOwnSymbol, 1, 1) \
F(CreatePrivateOwnSymbol, 1, 1) \
F(NewSymbolWrapper, 1, 1) \
F(SymbolDescription, 1, 1) \
F(SymbolRegistry, 0, 1) \
F(SymbolIsPrivate, 1, 1) \
\
/* Harmony proxies */ \
F(CreateJSProxy, 2, 1) \
F(CreateJSFunctionProxy, 4, 1) \
F(IsJSProxy, 1, 1) \
F(IsJSFunctionProxy, 1, 1) \
F(GetHandler, 1, 1) \
F(GetCallTrap, 1, 1) \
F(GetConstructTrap, 1, 1) \
F(Fix, 1, 1) \
\
/* Harmony sets */ \
F(SetInitialize, 1, 1) \
F(SetAdd, 2, 1) \
F(SetHas, 2, 1) \
F(SetDelete, 2, 1) \
F(SetClear, 1, 1) \
F(SetGetSize, 1, 1) \
\
F(SetIteratorInitialize, 3, 1) \
F(SetIteratorNext, 2, 1) \
\
/* Harmony maps */ \
F(MapInitialize, 1, 1) \
F(MapGet, 2, 1) \
F(MapHas, 2, 1) \
F(MapDelete, 2, 1) \
F(MapClear, 1, 1) \
F(MapSet, 3, 1) \
F(MapGetSize, 1, 1) \
\
F(MapIteratorInitialize, 3, 1) \
F(MapIteratorNext, 2, 1) \
\
/* Harmony weak maps and sets */ \
F(WeakCollectionInitialize, 1, 1) \
F(WeakCollectionGet, 2, 1) \
F(WeakCollectionHas, 2, 1) \
F(WeakCollectionDelete, 2, 1) \
F(WeakCollectionSet, 3, 1) \
\
F(GetWeakMapEntries, 1, 1) \
F(GetWeakSetValues, 1, 1) \
\
/* Harmony events */ \
F(EnqueueMicrotask, 1, 1) \
F(RunMicrotasks, 0, 1) \
\
/* Harmony observe */ \
F(IsObserved, 1, 1) \
F(SetIsObserved, 1, 1) \
F(GetObservationState, 0, 1) \
F(ObservationWeakMapCreate, 0, 1) \
F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
F(GetObjectContextObjectObserve, 1, 1) \
F(GetObjectContextObjectGetNotifier, 1, 1) \
F(GetObjectContextNotifierPerformChange, 1, 1) \
\
/* Harmony typed arrays */ \
F(ArrayBufferInitialize, 2, 1) \
F(ArrayBufferSliceImpl, 3, 1) \
F(ArrayBufferIsView, 1, 1) \
F(ArrayBufferNeuter, 1, 1) \
\
F(TypedArrayInitializeFromArrayLike, 4, 1) \
F(TypedArrayGetBuffer, 1, 1) \
F(TypedArraySetFastCases, 3, 1) \
\
F(DataViewGetBuffer, 1, 1) \
F(DataViewGetInt8, 3, 1) \
F(DataViewGetUint8, 3, 1) \
F(DataViewGetInt16, 3, 1) \
F(DataViewGetUint16, 3, 1) \
F(DataViewGetInt32, 3, 1) \
F(DataViewGetUint32, 3, 1) \
F(DataViewGetFloat32, 3, 1) \
F(DataViewGetFloat64, 3, 1) \
\
F(DataViewSetInt8, 4, 1) \
F(DataViewSetUint8, 4, 1) \
F(DataViewSetInt16, 4, 1) \
F(DataViewSetUint16, 4, 1) \
F(DataViewSetInt32, 4, 1) \
F(DataViewSetUint32, 4, 1) \
F(DataViewSetFloat32, 4, 1) \
F(DataViewSetFloat64, 4, 1) \
\
/* Statements */ \
F(NewObjectFromBound, 1, 1) \
\
/* Declarations and initialization */ \
F(InitializeVarGlobal, 3, 1) \
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
\
/* Debugging */ \
F(DebugPrint, 1, 1) \
F(GlobalPrint, 1, 1) \
F(DebugTrace, 0, 1) \
F(TraceEnter, 0, 1) \
F(TraceExit, 1, 1) \
F(Abort, 1, 1) \
F(AbortJS, 1, 1) \
/* ES5 */ \
F(OwnKeys, 1, 1) \
\
/* Message objects */ \
F(MessageGetStartPosition, 1, 1) \
F(MessageGetScript, 1, 1) \
\
/* Pseudo functions - handled as macros by parser */ \
F(IS_VAR, 1, 1) \
\
/* expose boolean functions from objects-inl.h */ \
F(HasFastSmiElements, 1, 1) \
F(HasFastSmiOrObjectElements, 1, 1) \
F(HasFastObjectElements, 1, 1) \
F(HasFastDoubleElements, 1, 1) \
F(HasFastHoleyElements, 1, 1) \
F(HasDictionaryElements, 1, 1) \
F(HasSloppyArgumentsElements, 1, 1) \
F(HasExternalUint8ClampedElements, 1, 1) \
F(HasExternalArrayElements, 1, 1) \
F(HasExternalInt8Elements, 1, 1) \
F(HasExternalUint8Elements, 1, 1) \
F(HasExternalInt16Elements, 1, 1) \
F(HasExternalUint16Elements, 1, 1) \
F(HasExternalInt32Elements, 1, 1) \
F(HasExternalUint32Elements, 1, 1) \
F(HasExternalFloat32Elements, 1, 1) \
F(HasExternalFloat64Elements, 1, 1) \
F(HasFixedUint8ClampedElements, 1, 1) \
F(HasFixedInt8Elements, 1, 1) \
F(HasFixedUint8Elements, 1, 1) \
F(HasFixedInt16Elements, 1, 1) \
F(HasFixedUint16Elements, 1, 1) \
F(HasFixedInt32Elements, 1, 1) \
F(HasFixedUint32Elements, 1, 1) \
F(HasFixedFloat32Elements, 1, 1) \
F(HasFixedFloat64Elements, 1, 1) \
F(HasFastProperties, 1, 1) \
F(TransitionElementsKind, 2, 1) \
F(HaveSameMap, 2, 1) \
F(IsJSGlobalProxy, 1, 1) \
F(ForInCacheArrayLength, 2, 1) /* TODO(turbofan): Only temporary */
@ -495,8 +493,6 @@ namespace internal {
F(PushBlockContext, 2, 1) \
F(PushModuleContext, 2, 1) \
F(DeleteLookupSlot, 2, 1) \
F(LoadLookupSlot, 2, 2) \
F(LoadLookupSlotNoReferenceError, 2, 2) \
F(StoreLookupSlot, 4, 1) \
\
/* Declarations and initialization */ \
@ -506,116 +502,121 @@ namespace internal {
F(InitializeConstGlobal, 2, 1) \
F(InitializeLegacyConstLookupSlot, 3, 1) \
\
/* Eval */ \
F(ResolvePossiblyDirectEval, 5, 2) \
\
/* Maths */ \
F(MathPowSlow, 2, 1) \
F(MathPowRT, 2, 1)
#define RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
/* Debugger support*/ \
F(DebugBreak, 0, 1) \
F(SetDebugEventListener, 2, 1) \
F(Break, 0, 1) \
F(DebugGetPropertyDetails, 2, 1) \
F(DebugGetProperty, 2, 1) \
F(DebugPropertyTypeFromDetails, 1, 1) \
F(DebugPropertyAttributesFromDetails, 1, 1) \
F(DebugPropertyIndexFromDetails, 1, 1) \
F(DebugNamedInterceptorPropertyValue, 2, 1) \
F(DebugIndexedInterceptorElementValue, 2, 1) \
F(CheckExecutionState, 1, 1) \
F(GetFrameCount, 1, 1) \
F(GetFrameDetails, 2, 1) \
F(GetScopeCount, 2, 1) \
F(GetStepInPositions, 2, 1) \
F(GetScopeDetails, 4, 1) \
F(GetAllScopesDetails, 4, 1) \
F(GetFunctionScopeCount, 1, 1) \
F(GetFunctionScopeDetails, 2, 1) \
F(SetScopeVariableValue, 6, 1) \
F(DebugPrintScopes, 0, 1) \
F(GetThreadCount, 1, 1) \
F(GetThreadDetails, 2, 1) \
F(SetDisableBreak, 1, 1) \
F(GetBreakLocations, 2, 1) \
F(SetFunctionBreakPoint, 3, 1) \
F(SetScriptBreakPoint, 4, 1) \
F(ClearBreakPoint, 1, 1) \
F(ChangeBreakOnException, 2, 1) \
F(IsBreakOnException, 1, 1) \
F(PrepareStep, 4, 1) \
F(ClearStepping, 0, 1) \
F(DebugEvaluate, 6, 1) \
F(DebugEvaluateGlobal, 4, 1) \
F(DebugGetLoadedScripts, 0, 1) \
F(DebugReferencedBy, 3, 1) \
F(DebugConstructedBy, 2, 1) \
F(DebugGetPrototype, 1, 1) \
F(DebugSetScriptSource, 2, 1) \
F(DebugCallbackSupportsStepping, 1, 1) \
F(SystemBreak, 0, 1) \
F(DebugDisassembleFunction, 1, 1) \
F(DebugDisassembleConstructor, 1, 1) \
F(FunctionGetInferredName, 1, 1) \
#define RUNTIME_FUNCTION_LIST_RETURN_PAIR(F) \
F(LoadLookupSlot, 2, 2) \
F(LoadLookupSlotNoReferenceError, 2, 2) \
F(ResolvePossiblyDirectEval, 5, 2) \
F(ForInInit, 2, 2) /* TODO(turbofan): Only temporary */ \
F(ForInNext, 4, 2) /* TODO(turbofan): Only temporary */
#define RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
/* Debugger support*/ \
F(DebugBreak, 0, 1) \
F(SetDebugEventListener, 2, 1) \
F(Break, 0, 1) \
F(DebugGetPropertyDetails, 2, 1) \
F(DebugGetProperty, 2, 1) \
F(DebugPropertyTypeFromDetails, 1, 1) \
F(DebugPropertyAttributesFromDetails, 1, 1) \
F(DebugPropertyIndexFromDetails, 1, 1) \
F(DebugNamedInterceptorPropertyValue, 2, 1) \
F(DebugIndexedInterceptorElementValue, 2, 1) \
F(CheckExecutionState, 1, 1) \
F(GetFrameCount, 1, 1) \
F(GetFrameDetails, 2, 1) \
F(GetScopeCount, 2, 1) \
F(GetStepInPositions, 2, 1) \
F(GetScopeDetails, 4, 1) \
F(GetAllScopesDetails, 4, 1) \
F(GetFunctionScopeCount, 1, 1) \
F(GetFunctionScopeDetails, 2, 1) \
F(SetScopeVariableValue, 6, 1) \
F(DebugPrintScopes, 0, 1) \
F(GetThreadCount, 1, 1) \
F(GetThreadDetails, 2, 1) \
F(SetDisableBreak, 1, 1) \
F(GetBreakLocations, 2, 1) \
F(SetFunctionBreakPoint, 3, 1) \
F(SetScriptBreakPoint, 4, 1) \
F(ClearBreakPoint, 1, 1) \
F(ChangeBreakOnException, 2, 1) \
F(IsBreakOnException, 1, 1) \
F(PrepareStep, 4, 1) \
F(ClearStepping, 0, 1) \
F(DebugEvaluate, 6, 1) \
F(DebugEvaluateGlobal, 4, 1) \
F(DebugGetLoadedScripts, 0, 1) \
F(DebugReferencedBy, 3, 1) \
F(DebugConstructedBy, 2, 1) \
F(DebugGetPrototype, 1, 1) \
F(DebugSetScriptSource, 2, 1) \
F(DebugCallbackSupportsStepping, 1, 1) \
F(SystemBreak, 0, 1) \
F(DebugDisassembleFunction, 1, 1) \
F(DebugDisassembleConstructor, 1, 1) \
F(FunctionGetInferredName, 1, 1) \
F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
F(LiveEditGatherCompileInfo, 2, 1) \
F(LiveEditReplaceScript, 3, 1) \
F(LiveEditReplaceFunctionCode, 2, 1) \
F(LiveEditFunctionSourceUpdated, 1, 1) \
F(LiveEditFunctionSetScript, 2, 1) \
F(LiveEditReplaceRefToNestedFunction, 3, 1) \
F(LiveEditPatchFunctionPositions, 2, 1) \
F(LiveEditCheckAndDropActivations, 2, 1) \
F(LiveEditCompareStrings, 2, 1) \
F(LiveEditRestartFrame, 2, 1) \
F(GetFunctionCodePositionFromSource, 2, 1) \
F(ExecuteInDebugContext, 2, 1) \
\
F(SetFlags, 1, 1) \
F(CollectGarbage, 1, 1) \
F(GetHeapUsage, 0, 1) \
F(LiveEditGatherCompileInfo, 2, 1) \
F(LiveEditReplaceScript, 3, 1) \
F(LiveEditReplaceFunctionCode, 2, 1) \
F(LiveEditFunctionSourceUpdated, 1, 1) \
F(LiveEditFunctionSetScript, 2, 1) \
F(LiveEditReplaceRefToNestedFunction, 3, 1) \
F(LiveEditPatchFunctionPositions, 2, 1) \
F(LiveEditCheckAndDropActivations, 2, 1) \
F(LiveEditCompareStrings, 2, 1) \
F(LiveEditRestartFrame, 2, 1) \
F(GetFunctionCodePositionFromSource, 2, 1) \
F(ExecuteInDebugContext, 2, 1) \
\
F(SetFlags, 1, 1) \
F(CollectGarbage, 1, 1) \
F(GetHeapUsage, 0, 1)
#ifdef V8_I18N_SUPPORT
#define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
/* i18n support */ \
/* Standalone, helper methods. */ \
F(CanonicalizeLanguageTag, 1, 1) \
F(AvailableLocalesOf, 1, 1) \
F(GetDefaultICULocale, 0, 1) \
F(GetLanguageTagVariants, 1, 1) \
F(IsInitializedIntlObject, 1, 1) \
F(IsInitializedIntlObjectOfType, 2, 1) \
F(MarkAsInitializedIntlObjectOfType, 3, 1) \
F(GetImplFromInitializedIntlObject, 1, 1) \
\
/* Date format and parse. */ \
F(CreateDateTimeFormat, 3, 1) \
F(InternalDateFormat, 2, 1) \
F(InternalDateParse, 2, 1) \
\
/* Number format and parse. */ \
F(CreateNumberFormat, 3, 1) \
F(InternalNumberFormat, 2, 1) \
F(InternalNumberParse, 2, 1) \
\
/* Collator. */ \
F(CreateCollator, 3, 1) \
F(InternalCompare, 3, 1) \
\
/* String.prototype.normalize. */ \
F(StringNormalize, 2, 1) \
\
/* Break iterator. */ \
F(CreateBreakIterator, 3, 1) \
F(BreakIteratorAdoptText, 2, 1) \
F(BreakIteratorFirst, 1, 1) \
F(BreakIteratorNext, 1, 1) \
F(BreakIteratorCurrent, 1, 1) \
F(BreakIteratorBreakType, 1, 1) \
/* i18n support */ \
/* Standalone, helper methods. */ \
F(CanonicalizeLanguageTag, 1, 1) \
F(AvailableLocalesOf, 1, 1) \
F(GetDefaultICULocale, 0, 1) \
F(GetLanguageTagVariants, 1, 1) \
F(IsInitializedIntlObject, 1, 1) \
F(IsInitializedIntlObjectOfType, 2, 1) \
F(MarkAsInitializedIntlObjectOfType, 3, 1) \
F(GetImplFromInitializedIntlObject, 1, 1) \
\
/* Date format and parse. */ \
F(CreateDateTimeFormat, 3, 1) \
F(InternalDateFormat, 2, 1) \
F(InternalDateParse, 2, 1) \
\
/* Number format and parse. */ \
F(CreateNumberFormat, 3, 1) \
F(InternalNumberFormat, 2, 1) \
F(InternalNumberParse, 2, 1) \
\
/* Collator. */ \
F(CreateCollator, 3, 1) \
F(InternalCompare, 3, 1) \
\
/* String.prototype.normalize. */ \
F(StringNormalize, 2, 1) \
\
/* Break iterator. */ \
F(CreateBreakIterator, 3, 1) \
F(BreakIteratorAdoptText, 2, 1) \
F(BreakIteratorFirst, 1, 1) \
F(BreakIteratorNext, 1, 1) \
F(BreakIteratorCurrent, 1, 1) \
F(BreakIteratorBreakType, 1, 1)
#else
#define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
@ -624,7 +625,7 @@ namespace internal {
#ifdef DEBUG
#define RUNTIME_FUNCTION_LIST_DEBUG(F) \
/* Testing */ \
/* Testing */ \
F(ListNatives, 0, 1)
#else
#define RUNTIME_FUNCTION_LIST_DEBUG(F)
@ -636,14 +637,19 @@ namespace internal {
// via a native call by name (from within JS code).
// Entries have the form F(name, number of arguments, number of return values).
#define RUNTIME_FUNCTION_LIST(F) \
RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
RUNTIME_FUNCTION_LIST_DEBUG(F) \
RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
#define RUNTIME_FUNCTION_LIST_RETURN_OBJECT(F) \
RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
RUNTIME_FUNCTION_LIST_DEBUG(F) \
RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
#define RUNTIME_FUNCTION_LIST(F) \
RUNTIME_FUNCTION_LIST_RETURN_OBJECT(F) \
RUNTIME_FUNCTION_LIST_RETURN_PAIR(F)
// ----------------------------------------------------------------------------
// INLINE_FUNCTION_LIST defines all inlined functions accessed
// with a native call of the form %_name from within JS code.
@ -698,21 +704,21 @@ namespace internal {
// directly as %name (i.e. without the leading underscore).
// Entries have the form F(name, number of arguments, number of return values).
#define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
/* Typed Arrays */ \
F(TypedArrayInitialize, 5, 1) \
F(DataViewInitialize, 4, 1) \
F(MaxSmi, 0, 1) \
F(TypedArrayMaxSizeInHeap, 0, 1) \
F(ArrayBufferViewGetByteLength, 1, 1) \
F(ArrayBufferViewGetByteOffset, 1, 1) \
F(TypedArrayGetLength, 1, 1) \
/* ArrayBuffer */ \
F(ArrayBufferGetByteLength, 1, 1) \
/* Maths */ \
F(ConstructDouble, 2, 1) \
F(DoubleHi, 1, 1) \
F(DoubleLo, 1, 1) \
F(MathSqrtRT, 1, 1) \
/* Typed Arrays */ \
F(TypedArrayInitialize, 5, 1) \
F(DataViewInitialize, 4, 1) \
F(MaxSmi, 0, 1) \
F(TypedArrayMaxSizeInHeap, 0, 1) \
F(ArrayBufferViewGetByteLength, 1, 1) \
F(ArrayBufferViewGetByteOffset, 1, 1) \
F(TypedArrayGetLength, 1, 1) \
/* ArrayBuffer */ \
F(ArrayBufferGetByteLength, 1, 1) \
/* Maths */ \
F(ConstructDouble, 2, 1) \
F(DoubleHi, 1, 1) \
F(DoubleLo, 1, 1) \
F(MathSqrtRT, 1, 1) \
F(MathLogRT, 1, 1)
@ -765,8 +771,7 @@ class Runtime : public AllStatic {
public:
enum FunctionId {
#define F(name, nargs, ressize) k##name,
RUNTIME_FUNCTION_LIST(F)
INLINE_OPTIMIZED_FUNCTION_LIST(F)
RUNTIME_FUNCTION_LIST(F) INLINE_OPTIMIZED_FUNCTION_LIST(F)
#undef F
#define F(name, nargs, ressize) kInline##name,
INLINE_FUNCTION_LIST(F)
@ -778,11 +783,7 @@ class Runtime : public AllStatic {
kFirstInlineFunction = kInlineIsSmi
};
enum IntrinsicType {
RUNTIME,
INLINE,
INLINE_OPTIMIZED
};
enum IntrinsicType { RUNTIME, INLINE, INLINE_OPTIMIZED };
// Intrinsic function descriptor.
struct Function {
@ -818,10 +819,8 @@ class Runtime : public AllStatic {
static const Function* FunctionForEntry(Address ref);
// General-purpose helper functions for runtime system.
static int StringMatch(Isolate* isolate,
Handle<String> sub,
Handle<String> pat,
int index);
static int StringMatch(Isolate* isolate, Handle<String> sub,
Handle<String> pat, int index);
static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch);
@ -831,9 +830,7 @@ class Runtime : public AllStatic {
// Support getting the characters in a string using [] notation as
// in Firefox/SpiderMonkey, Safari and Opera.
MUST_USE_RESULT static MaybeHandle<Object> GetElementOrCharAt(
Isolate* isolate,
Handle<Object> object,
uint32_t index);
Isolate* isolate, Handle<Object> object, uint32_t index);
MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key,
@ -844,38 +841,29 @@ class Runtime : public AllStatic {
PropertyAttributes attr);
MUST_USE_RESULT static MaybeHandle<Object> DeleteObjectProperty(
Isolate* isolate,
Handle<JSReceiver> object,
Handle<Object> key,
Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key,
JSReceiver::DeleteMode mode);
MUST_USE_RESULT static MaybeHandle<Object> HasObjectProperty(
Isolate* isolate,
Handle<JSReceiver> object,
Handle<Object> key);
Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key);
MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
Isolate* isolate,
Handle<Object> object,
Handle<Object> key);
Isolate* isolate, Handle<Object> object, Handle<Object> key);
static void SetupArrayBuffer(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer,
bool is_external,
void* data,
bool is_external, void* data,
size_t allocated_length);
static bool SetupArrayBufferAllocatingData(
Isolate* isolate,
Handle<JSArrayBuffer> array_buffer,
size_t allocated_length,
bool initialize = true);
static bool SetupArrayBufferAllocatingData(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer,
size_t allocated_length,
bool initialize = true);
static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
static void FreeArrayBuffer(
Isolate* isolate,
JSArrayBuffer* phantom_array_buffer);
static void FreeArrayBuffer(Isolate* isolate,
JSArrayBuffer* phantom_array_buffer);
enum TypedArrayId {
// arrayIds below should be synchromized with typedarray.js natives.
@ -888,21 +876,18 @@ class Runtime : public AllStatic {
ARRAY_ID_FLOAT32 = 7,
ARRAY_ID_FLOAT64 = 8,
ARRAY_ID_UINT8_CLAMPED = 9,
ARRAY_ID_FIRST = ARRAY_ID_UINT8,
ARRAY_ID_LAST = ARRAY_ID_UINT8_CLAMPED
};
static void ArrayIdToTypeAndSize(int array_id,
ExternalArrayType *type,
ElementsKind* external_elements_kind,
ElementsKind* fixed_elements_kind,
size_t *element_size);
static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType* type,
ElementsKind* external_elements_kind,
ElementsKind* fixed_elements_kind,
size_t* element_size);
// Used in runtime.cc and hydrogen's VisitArrayLiteral.
MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
Isolate* isolate,
Handle<FixedArray> literals,
Isolate* isolate, Handle<FixedArray> literals,
Handle<FixedArray> elements);
};
@ -910,13 +895,13 @@ class Runtime : public AllStatic {
//---------------------------------------------------------------------------
// Constants used by interface to runtime functions.
class AllocateDoubleAlignFlag: public BitField<bool, 0, 1> {};
class AllocateTargetSpace: public BitField<AllocationSpace, 1, 3> {};
class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {};
class AllocateTargetSpace : public BitField<AllocationSpace, 1, 3> {};
class DeclareGlobalsEvalFlag: public BitField<bool, 0, 1> {};
class DeclareGlobalsNativeFlag: public BitField<bool, 1, 1> {};
class DeclareGlobalsStrictMode: public BitField<StrictMode, 2, 1> {};
} } // namespace v8::internal
class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
class DeclareGlobalsStrictMode : public BitField<StrictMode, 2, 1> {};
}
} // namespace v8::internal
#endif // V8_RUNTIME_H_

View File

@ -16,7 +16,7 @@
#include "src/ic/stub-cache.h"
#include "src/natives.h"
#include "src/objects.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/serialize.h"
#include "src/snapshot.h"
#include "src/snapshot-source-sink.h"

View File

@ -14,7 +14,7 @@
#include "src/isolate.h"
#include "src/jsregexp.h"
#include "src/regexp-macro-assembler.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -15,7 +15,7 @@
#include "src/isolate.h"
#include "src/jsregexp.h"
#include "src/regexp-macro-assembler.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {

View File

@ -13,7 +13,7 @@
#include "src/cpu-profiler.h"
#include "src/debug.h"
#include "src/isolate-inl.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/serialize.h"
namespace v8 {

View File

@ -30,7 +30,7 @@
#include "src/api.h"
#include "src/debug.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "test/cctest/cctest.h"

View File

@ -37,7 +37,7 @@
#include "src/heap/spaces.h"
#include "src/natives.h"
#include "src/objects.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/scopeinfo.h"
#include "src/serialize.h"
#include "src/snapshot.h"

View File

@ -8,7 +8,7 @@ import os
import re
import sys
FILENAME = "src/runtime.h"
FILENAME = "src/runtime/runtime.h"
LISTHEAD = re.compile(r"#define\s+(\w+LIST\w*)\((\w+)\)")
LISTBODY = re.compile(r".*\\$")
BLACKLIST = ['INLINE_FUNCTION_LIST']

View File

@ -731,8 +731,10 @@
'../../src/rewriter.h',
'../../src/runtime-profiler.cc',
'../../src/runtime-profiler.h',
'../../src/runtime.cc',
'../../src/runtime.h',
'../../src/runtime/runtime-i18n.cc',
'../../src/runtime/runtime-utils.h',
'../../src/runtime/runtime.cc',
'../../src/runtime/runtime.h',
'../../src/safepoint-table.cc',
'../../src/safepoint-table.h',
'../../src/sampler.cc',

View File

@ -37,7 +37,7 @@
#include "src/api.h"
#include "src/base/platform/platform.h"
#include "src/messages.h"
#include "src/runtime.h"
#include "src/runtime/runtime.h"
#include "src/scanner-character-streams.h"
#include "src/scopeinfo.h"
#include "tools/shell-utils.h"