Remove builtin/runtime name clash presubmit check.
authoryangguo <yangguo@chromium.org>
Thu, 27 Aug 2015 11:13:56 +0000 (04:13 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 27 Aug 2015 11:14:09 +0000 (11:14 +0000)
It has become obsolete since we do the name lookup at compile time.

R=bmeurer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30405}

PRESUBMIT.py
src/parser.cc
src/runtime.js
tools/check-name-clashes.py [deleted file]
tools/presubmit.py

index 1bcd9922c56aeddd3199456e1143a291d97cd1b7..c9a8a99de4c3e1cca190b563f69e6c5918304c8a 100644 (file)
@@ -67,7 +67,6 @@ def _V8PresubmitChecks(input_api, output_api):
         input_api.PresubmitLocalPath(), 'tools'))
   from presubmit import CppLintProcessor
   from presubmit import SourceProcessor
-  from presubmit import CheckRuntimeVsNativesNameClashes
   from presubmit import CheckExternalReferenceRegistration
   from presubmit import CheckAuthorizedAuthor
 
@@ -78,9 +77,6 @@ def _V8PresubmitChecks(input_api, output_api):
     results.append(output_api.PresubmitError(
         "Copyright header, trailing whitespaces and two empty lines " \
         "between declarations check failed"))
-  if not CheckRuntimeVsNativesNameClashes(input_api.PresubmitLocalPath()):
-    results.append(output_api.PresubmitError(
-        "Runtime/natives name clash check failed"))
   if not CheckExternalReferenceRegistration(input_api.PresubmitLocalPath()):
     results.append(output_api.PresubmitError(
         "External references registration check failed"))
index 71b1e558c29411a009c1382492b3643e5a365bf4..3f635c70df275ea837606aa81354f6daea36a882 100644 (file)
@@ -4739,6 +4739,9 @@ Expression* Parser::ParseV8Intrinsic(bool* ok) {
   const Runtime::Function* function = Runtime::FunctionForName(name->string());
 
   if (function != NULL) {
+    // Check for possible name clash.
+    DCHECK_EQ(Context::kNotFound,
+              Context::IntrinsicIndexForName(name->string()));
     // Check for built-in IS_VAR macro.
     if (function->function_id == Runtime::kIS_VAR) {
       DCHECK_EQ(Runtime::RUNTIME, function->intrinsic_type);
index bbffef268b093d365b739601cb28e42d94d1a252..1503373d4a3fc6c78cc2630b039800f30c338b08 100644 (file)
@@ -63,7 +63,9 @@ function EQUALS(y) {
       while (true) {
         if (IS_STRING(y)) return %StringEquals(x, y);
         if (IS_NUMBER(y)) return %NumberEquals(%to_number_fun(x), y);
-        if (IS_BOOLEAN(y)) return %NumberEquals(%to_number_fun(x), %to_number_fun(y));
+        if (IS_BOOLEAN(y)) {
+          return %NumberEquals(%to_number_fun(x), %to_number_fun(y));
+        }
         if (IS_NULL_OR_UNDEFINED(y)) return 1;  // not equal
         if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1;  // not equal
         y = %to_primitive(y, NO_HINT);
@@ -75,7 +77,9 @@ function EQUALS(y) {
       if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1;
       if (IS_NULL_OR_UNDEFINED(y)) return 1;
       if (IS_NUMBER(y)) return %NumberEquals(%to_number_fun(x), y);
-      if (IS_STRING(y)) return %NumberEquals(%to_number_fun(x), %to_number_fun(y));
+      if (IS_STRING(y)) {
+        return %NumberEquals(%to_number_fun(x), %to_number_fun(y));
+      }
       if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1;  // not equal
       // y is object.
       x = %to_number_fun(x);
diff --git a/tools/check-name-clashes.py b/tools/check-name-clashes.py
deleted file mode 100755 (executable)
index 25f3aac..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/env python
-# 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.
-
-import js2c
-import os
-import re
-import sys
-
-FILENAME = "src/runtime/runtime.h"
-LISTHEAD = re.compile(r"#define\s+(FOR_EACH_\w+)\((\w+)\)")
-LISTBODY = re.compile(r".*\\$")
-
-
-class Function(object):
-  def __init__(self, match):
-    self.name = match.group(1).strip()
-
-def ListMacroRe(list):
-  macro = LISTHEAD.match(list[0]).group(2)
-  re_string = "\s*%s\((\w+)" % macro
-  return re.compile(re_string)
-
-
-def FindLists(filename):
-  lists = []
-  current_list = []
-  mode = "SEARCHING"
-  with open(filename, "r") as f:
-    for line in f:
-      if mode == "SEARCHING":
-        match = LISTHEAD.match(line)
-        if match:
-          mode = "APPENDING"
-          current_list.append(line)
-      else:
-        current_list.append(line)
-        match = LISTBODY.match(line)
-        if not match:
-          mode = "SEARCHING"
-          lists.append(current_list)
-          current_list = []
-  return lists
-
-
-# Detects runtime functions by parsing FILENAME.
-def FindRuntimeFunctions():
-  functions = []
-  lists = FindLists(FILENAME)
-  for list in lists:
-    function_re = ListMacroRe(list)
-    for line in list:
-      match = function_re.match(line)
-      if match:
-        functions.append(Function(match))
-  return functions
-
-
-class Builtin(object):
-  def __init__(self, match):
-    self.name = match.group(1)
-
-
-def FindJSNatives():
-  PATH = "src"
-  fileslist = []
-  for (root, dirs, files) in os.walk(PATH):
-    for f in files:
-      if f.endswith(".js"):
-        fileslist.append(os.path.join(root, f))
-  natives = []
-  regexp = re.compile("^function (\w+)\s*\((.*?)\) {")
-  matches = 0
-  for filename in fileslist:
-    with open(filename, "r") as f:
-      file_contents = f.read()
-    file_contents = js2c.ExpandInlineMacros(file_contents)
-    lines = file_contents.split("\n")
-    partial_line = ""
-    for line in lines:
-      if line.startswith("function") and not '{' in line:
-        partial_line += line.rstrip()
-        continue
-      if partial_line:
-        partial_line += " " + line.strip()
-        if '{' in line:
-          line = partial_line
-          partial_line = ""
-        else:
-          continue
-      match = regexp.match(line)
-      if match:
-        natives.append(Builtin(match))
-  return natives
-
-
-def Main():
-  functions = FindRuntimeFunctions()
-  natives = FindJSNatives()
-  errors = 0
-  runtime_map = {}
-  for f in functions:
-    runtime_map[f.name] = 1
-  for b in natives:
-    if b.name in runtime_map:
-      print("JS_Native/Runtime_Function name clash: %s" % b.name)
-      errors += 1
-
-  if errors > 0:
-    return 1
-  print("Runtime/Natives name clashes: checked %d/%d functions, all good." %
-        (len(functions), len(natives)))
-  return 0
-
-
-if __name__ == "__main__":
-  sys.exit(Main())
index a835e61792caad2f6858412c2263e0ce78fc2877..078a09ace7e77caa64195efbf4c7fe61336f92fb 100755 (executable)
@@ -438,12 +438,6 @@ class SourceProcessor(SourceFileProcessor):
     return success
 
 
-def CheckRuntimeVsNativesNameClashes(workspace):
-  code = subprocess.call(
-      [sys.executable, join(workspace, "tools", "check-name-clashes.py")])
-  return code == 0
-
-
 def CheckExternalReferenceRegistration(workspace):
   code = subprocess.call(
       [sys.executable, join(workspace, "tools", "external-reference-check.py")])
@@ -495,7 +489,6 @@ def Main():
   print "Running copyright header, trailing whitespaces and " \
         "two empty lines between declarations check..."
   success = SourceProcessor().Run(workspace) and success
-  success = CheckRuntimeVsNativesNameClashes(workspace) and success
   success = CheckExternalReferenceRegistration(workspace) and success
   if success:
     return 0