Commit af635205 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Split yet more runtime functions into separate files.

R=bmeurer@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24323 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c1ee6247
...@@ -831,13 +831,19 @@ source_set("v8_base") { ...@@ -831,13 +831,19 @@ source_set("v8_base") {
"src/runtime/runtime-i18n.cc", "src/runtime/runtime-i18n.cc",
"src/runtime/runtime-date.cc", "src/runtime/runtime-date.cc",
"src/runtime/runtime-debug.cc", "src/runtime/runtime-debug.cc",
"src/runtime/runtime-function.cc",
"src/runtime/runtime-generator.cc", "src/runtime/runtime-generator.cc",
"src/runtime/runtime-json.cc", "src/runtime/runtime-json.cc",
"src/runtime/runtime-literals.cc",
"src/runtime/runtime-liveedit.cc", "src/runtime/runtime-liveedit.cc",
"src/runtime/runtime-maths.cc", "src/runtime/runtime-maths.cc",
"src/runtime/runtime-numbers.cc", "src/runtime/runtime-numbers.cc",
"src/runtime/runtime-observe.cc",
"src/runtime/runtime-proxy.cc",
"src/runtime/runtime-regexp.cc", "src/runtime/runtime-regexp.cc",
"src/runtime/runtime-scopes.cc",
"src/runtime/runtime-strings.cc", "src/runtime/runtime-strings.cc",
"src/runtime/runtime-symbol.cc",
"src/runtime/runtime-test.cc", "src/runtime/runtime-test.cc",
"src/runtime/runtime-typedarray.cc", "src/runtime/runtime-typedarray.cc",
"src/runtime/runtime-uri.cc", "src/runtime/runtime-uri.cc",
......
This diff is collapsed.
This diff is collapsed.
...@@ -561,5 +561,22 @@ RUNTIME_FUNCTION(RuntimeReference_NumberToString) { ...@@ -561,5 +561,22 @@ RUNTIME_FUNCTION(RuntimeReference_NumberToString) {
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
return __RT_impl_Runtime_NumberToStringRT(args, isolate); return __RT_impl_Runtime_NumberToStringRT(args, isolate);
} }
RUNTIME_FUNCTION(RuntimeReference_IsSmi) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(Object, obj, 0);
return isolate->heap()->ToBoolean(obj->IsSmi());
}
RUNTIME_FUNCTION(RuntimeReference_IsNonNegativeSmi) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(Object, obj, 0);
return isolate->heap()->ToBoolean(obj->IsSmi() &&
Smi::cast(obj)->value() >= 0);
}
} }
} // namespace v8::internal } // namespace v8::internal
// 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/arguments.h"
#include "src/runtime/runtime.h"
#include "src/runtime/runtime-utils.h"
namespace v8 {
namespace internal {
RUNTIME_FUNCTION(Runtime_IsObserved) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value();
CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
DCHECK(!obj->IsJSGlobalProxy() || !obj->map()->is_observed());
return isolate->heap()->ToBoolean(obj->map()->is_observed());
}
RUNTIME_FUNCTION(Runtime_SetIsObserved) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
RUNTIME_ASSERT(!obj->IsJSGlobalProxy());
if (obj->IsJSProxy()) return isolate->heap()->undefined_value();
RUNTIME_ASSERT(!obj->map()->is_observed());
DCHECK(obj->IsJSObject());
JSObject::SetObserved(Handle<JSObject>::cast(obj));
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, microtask, 0);
isolate->EnqueueMicrotask(microtask);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_RunMicrotasks) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
isolate->RunMicrotasks();
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_GetObservationState) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 0);
return isolate->heap()->observation_state();
}
static bool ContextsHaveSameOrigin(Handle<Context> context1,
Handle<Context> context2) {
return context1->security_token() == context2->security_token();
}
RUNTIME_FUNCTION(Runtime_ObserverObjectAndRecordHaveSameOrigin) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2);
Handle<Context> observer_context(observer->context()->native_context());
Handle<Context> object_context(object->GetCreationContext());
Handle<Context> record_context(record->GetCreationContext());
return isolate->heap()->ToBoolean(
ContextsHaveSameOrigin(object_context, observer_context) &&
ContextsHaveSameOrigin(object_context, record_context));
}
RUNTIME_FUNCTION(Runtime_ObjectWasCreatedInCurrentOrigin) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
Handle<Context> creation_context(object->GetCreationContext(), isolate);
return isolate->heap()->ToBoolean(
ContextsHaveSameOrigin(creation_context, isolate->native_context()));
}
RUNTIME_FUNCTION(Runtime_GetObjectContextObjectObserve) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
Handle<Context> context(object->GetCreationContext(), isolate);
return context->native_object_observe();
}
RUNTIME_FUNCTION(Runtime_GetObjectContextObjectGetNotifier) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
Handle<Context> context(object->GetCreationContext(), isolate);
return context->native_object_get_notifier();
}
RUNTIME_FUNCTION(Runtime_GetObjectContextNotifierPerformChange) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object_info, 0);
Handle<Context> context(object_info->GetCreationContext(), isolate);
return context->native_object_notifier_perform_change();
}
}
} // namespace v8::internal
// 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/arguments.h"
#include "src/runtime/runtime.h"
#include "src/runtime/runtime-utils.h"
namespace v8 {
namespace internal {
RUNTIME_FUNCTION(Runtime_CreateJSProxy) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
return *isolate->factory()->NewJSProxy(handler, prototype);
}
RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) {
HandleScope scope(isolate);
DCHECK(args.length() == 4);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1);
RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2);
CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3);
if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
return *isolate->factory()->NewJSFunctionProxy(handler, call_trap,
construct_trap, prototype);
}
RUNTIME_FUNCTION(Runtime_IsJSProxy) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
return isolate->heap()->ToBoolean(obj->IsJSProxy());
}
RUNTIME_FUNCTION(Runtime_IsJSFunctionProxy) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy());
}
RUNTIME_FUNCTION(Runtime_GetHandler) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
return proxy->handler();
}
RUNTIME_FUNCTION(Runtime_GetCallTrap) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
return proxy->call_trap();
}
RUNTIME_FUNCTION(Runtime_GetConstructTrap) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
return proxy->construct_trap();
}
RUNTIME_FUNCTION(Runtime_Fix) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0);
JSProxy::Fix(proxy);
return isolate->heap()->undefined_value();
}
}
} // namespace v8::internal
...@@ -1088,6 +1088,14 @@ RUNTIME_FUNCTION(RuntimeReference_RegExpExec) { ...@@ -1088,6 +1088,14 @@ RUNTIME_FUNCTION(RuntimeReference_RegExpExec) {
} }
RUNTIME_FUNCTION(RuntimeReference_IsRegExp) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(Object, obj, 0);
return isolate->heap()->ToBoolean(obj->IsJSRegExp());
}
// Perform string match of pattern on subject, starting at start index. // Perform string match of pattern on subject, starting at start index.
// Caller must ensure that 0 <= start_index <= sub->length(), // Caller must ensure that 0 <= start_index <= sub->length(),
// and should check that pat->length() + start_index <= sub->length(). // and should check that pat->length() + start_index <= sub->length().
......
This diff is collapsed.
// 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/arguments.h"
#include "src/runtime/runtime.h"
#include "src/runtime/runtime-utils.h"
namespace v8 {
namespace internal {
RUNTIME_FUNCTION(Runtime_CreateSymbol) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
Handle<Symbol> symbol = isolate->factory()->NewSymbol();
if (name->IsString()) symbol->set_name(*name);
return *symbol;
}
RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol();
if (name->IsString()) symbol->set_name(*name);
return *symbol;
}
RUNTIME_FUNCTION(Runtime_CreatePrivateOwnSymbol) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
Handle<Symbol> symbol = isolate->factory()->NewPrivateOwnSymbol();
if (name->IsString()) symbol->set_name(*name);
return *symbol;
}
RUNTIME_FUNCTION(Runtime_CreateGlobalPrivateOwnSymbol) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
Handle<JSObject> registry = isolate->GetSymbolRegistry();
Handle<String> part = isolate->factory()->private_intern_string();
Handle<Object> privates;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, privates, Object::GetPropertyOrElement(registry, part));
Handle<Object> symbol;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, symbol, Object::GetPropertyOrElement(privates, name));
if (!symbol->IsSymbol()) {
DCHECK(symbol->IsUndefined());
symbol = isolate->factory()->NewPrivateSymbol();
Handle<Symbol>::cast(symbol)->set_name(*name);
Handle<Symbol>::cast(symbol)->set_is_own(true);
JSObject::SetProperty(Handle<JSObject>::cast(privates), name, symbol,
STRICT).Assert();
}
return *symbol;
}
RUNTIME_FUNCTION(Runtime_NewSymbolWrapper) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0);
return *Object::ToObject(isolate, symbol).ToHandleChecked();
}
RUNTIME_FUNCTION(Runtime_SymbolDescription) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(Symbol, symbol, 0);
return symbol->name();
}
RUNTIME_FUNCTION(Runtime_SymbolRegistry) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
return *isolate->GetSymbolRegistry();
}
RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(Symbol, symbol, 0);
return isolate->heap()->ToBoolean(symbol->is_private());
}
}
} // namespace v8::internal
...@@ -303,6 +303,53 @@ RUNTIME_FUNCTION(Runtime_GetV8Version) { ...@@ -303,6 +303,53 @@ RUNTIME_FUNCTION(Runtime_GetV8Version) {
} }
static int StackSize(Isolate* isolate) {
int n = 0;
for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++;
return n;
}
static void PrintTransition(Isolate* isolate, Object* result) {
// indentation
{
const int nmax = 80;
int n = StackSize(isolate);
if (n <= nmax)
PrintF("%4d:%*s", n, n, "");
else
PrintF("%4d:%*s", n, nmax, "...");
}
if (result == NULL) {
JavaScriptFrame::PrintTop(isolate, stdout, true, false);
PrintF(" {\n");
} else {
// function result
PrintF("} -> ");
result->ShortPrint();
PrintF("\n");
}
}
RUNTIME_FUNCTION(Runtime_TraceEnter) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 0);
PrintTransition(isolate, NULL);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_TraceExit) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(Object, obj, 0);
PrintTransition(isolate, obj);
return obj; // return TOS
}
#ifdef DEBUG #ifdef DEBUG
// ListNatives is ONLY used by the fuzz-natives.js in debug mode // ListNatives is ONLY used by the fuzz-natives.js in debug mode
// Exclude the code in release mode. // Exclude the code in release mode.
......
This diff is collapsed.
...@@ -741,14 +741,20 @@ ...@@ -741,14 +741,20 @@
'../../src/runtime/runtime-compiler.cc', '../../src/runtime/runtime-compiler.cc',
'../../src/runtime/runtime-date.cc', '../../src/runtime/runtime-date.cc',
'../../src/runtime/runtime-debug.cc', '../../src/runtime/runtime-debug.cc',
'../../src/runtime/runtime-function.cc',
'../../src/runtime/runtime-generator.cc', '../../src/runtime/runtime-generator.cc',
'../../src/runtime/runtime-i18n.cc', '../../src/runtime/runtime-i18n.cc',
'../../src/runtime/runtime-json.cc', '../../src/runtime/runtime-json.cc',
'../../src/runtime/runtime-literals.cc',
'../../src/runtime/runtime-liveedit.cc', '../../src/runtime/runtime-liveedit.cc',
'../../src/runtime/runtime-maths.cc', '../../src/runtime/runtime-maths.cc',
'../../src/runtime/runtime-numbers.cc', '../../src/runtime/runtime-numbers.cc',
'../../src/runtime/runtime-observe.cc',
'../../src/runtime/runtime-proxy.cc',
'../../src/runtime/runtime-regexp.cc', '../../src/runtime/runtime-regexp.cc',
'../../src/runtime/runtime-scopes.cc',
'../../src/runtime/runtime-strings.cc', '../../src/runtime/runtime-strings.cc',
'../../src/runtime/runtime-symbol.cc',
'../../src/runtime/runtime-test.cc', '../../src/runtime/runtime-test.cc',
'../../src/runtime/runtime-typedarray.cc', '../../src/runtime/runtime-typedarray.cc',
'../../src/runtime/runtime-uri.cc', '../../src/runtime/runtime-uri.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment